-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for .NET Hot Reload #232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
samples/CommunityToolkit.Maui.Markup.Sample/HotReloadHandler.cs
Outdated
Show resolved
Hide resolved
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 ✅ |
samples/CommunityToolkit.Maui.Markup.Sample/HotReloadHandler.cs
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Markup.Sample/HotReloadHandler.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Vladislav Antonyuk <[email protected]>
Description
This PR implements
MetadataUpdateHandler
which 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:
ICommunityToolkitHotReloadHandler
ICommunityToolkitHotReloadHandler.OnHotReload()
, specify how to update the visible pageShell
example belowIn
MauiProgram.CreateMauiApp()
, add your implementation ofICommunityToolkitHotReloadHandler
:Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at 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
ICommunityToolkitHotReloadHandler
because 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()
.