Add Support for .NET Hot Reload#232
Conversation
pictos
left a comment
There was a problem hiding this comment.
I liked the interface idea and let devs opt-in to use the feature. I didn't have my PC with me to test everything, so the comment about the debug flag is a guess
|
I like that the To illustrate, here is a reload handler for WPF in C# Markup 2 - the same logic applies. I also applaud that no standard handler implementation is shipped; I expect that for non-trivial Apps this logic will need to be customized by the app developer. Imo it would be fine to keep the handler at a simple implementation in docs, as the PR description proposes, or perhaps as part of a (dotnet new?) template |
In the PR description, the |
|
Thanks Vincent!
Whoops - that was just a lazy copy/paste edit from the source code into the PR description. Fixed ✅ |
Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Description
This PR implements
MetadataUpdateHandlerwhich is required for libraries wishing to support C# Hot Reload.While C# Hot Reload does update the running/active C# code, it will not automatically refresh the visible .NET MAUI UI. To refresh the displayed UI, .NET MAUI devs are required to write additional code specific to their app that invalidates the current view.
For this initial implementation, developers will need to do two things:
ICommunityToolkitHotReloadHandlerICommunityToolkitHotReloadHandler.OnHotReload(), specify how to update the visible pageShellexample belowIn
MauiProgram.CreateMauiApp(), add your implementation ofICommunityToolkitHotReloadHandler:Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
While C# Hot Reload does update the running/active C# code, it will not refresh the .NET MAUI UI. To refresh the displayed UI, .NET MAUI devs are required to write additional code specific to their app that invalidates the
For this initial implementation of C# Hot Reload support, I recommend that we do not provide a default implementation of
ICommunityToolkitHotReloadHandlerbecause it is near impossible to account for every application architecture.I have included in this PR (and I recommend including in the docs) a sample implementation of
ICommunityToolkitHotReloadHandler.In future releases, once we are comfortable with a stable implementation of
ICommunityToolkitHotReloadHandler, we can wire it up automatically for the users inUseMauiCommunityToolkitMarkup().