Page 1 of 1

Hot reload of global resources

Posted: 10 May 2022, 17:53
by anton.sodergren_pdx
Hi, I just wanted to check something about hot reloading.

Whenever a XAML file for a window is changed while the game is running, it is properly reloaded. However, when a XAML file containing global resources is changed, we do call RaiseXamlChanged, but nothing seems to happen.

Is this the expected behaviour? Is there simply no support for hot reloading global resource files? And if that is the case, are there any plans for implementing support for this?

Re: Hot reload of global resources

Posted: 12 May 2022, 19:02
by sfernandez
Hi Anton,

Reloading ResourceDictionaries is not working yet, only xamls of objects connected to the visual tree are reloaded right now.
We have plans to implement support for that in the following major version.

Re: Hot reload of global resources

Posted: 29 Oct 2024, 17:56
by anton.sodergren_pdx
Hello again! It was a while since I made this thread, but I want to revive it since this is very much related.

Is it correct that hot reloading of global resources was implemented? The patch notes for 3.2 mentioned that the hot reload algorithm was reimplemented. And the documentation page for Hot Reload mentions resource dictionaries and theme modifications, so I would make the assumption that it is now supposed to work.

For quite a while now, we have had a file watcher that has manually brute force reloaded everything, including both resource dictionaries and all views, whenever any XAML file changes, since we couldn't rely on the built-in hot reload functionality due to the missing support for global resources. But as you can imagine, this is quite slow to do whenever a XAML file changes. So we wanted to do another attempt at making use of the built-in functionality instead. After having hooked up our file watcher to notify the XAML provider, hot reloading user controls or resource dictionaries that are referenced as merged dictionaries from the user controls work just as I would expect, and it is quite quick! However, for XAML files that are global resources, it seems like nothing is happening, and in the log file it doesn't look like it's trying to load the file.

Do we need to do something special for hot reloading of global resources, or is it still just not implemented? We are currently on version 3.2.3.

Re: Hot reload of global resources

Posted: 30 Oct 2024, 18:52
by jsantos
Yes, this approach should work. If you manually merge the global dictionary XAML into one of your existing XAML files, do the resources reload correctly in that case?

Could you please create a ticket for this issue?

Re: Hot reload of global resources

Posted: 31 Oct 2024, 11:13
by anton.sodergren_pdx
Hey, indeed if I simply add it to a merged dictionary in the view, it does actually reload as expected for that view. But if it's just used as a global resource, the file doesn't reload (LoadXaml in the XAML provider doesn't get called even though the XAML provider is notified that the file has changed).

Sure, I can create a ticket.

Re: Hot reload of global resources

Posted: 31 Oct 2024, 14:33
by anton.sodergren_pdx
I created this ticket for the issue:

https://www.noesisengine.com/bugs/view.php?id=3765

Re: Hot reload of global resources

Posted: 05 Nov 2024, 12:16
by sfernandez
Thanks!