-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Summary
The MAUI codebase contains a complex, non-functional HotReload infrastructure that was intended for .NET hot reload support via metadata updates. This infrastructure is:
- Not registered - No
[assembly: MetadataUpdateHandler(...)]attribute exists in MAUI Core or Controls - Not called - No metadata update entry points are invoked
- Unused - No callers to
Register/UnRegister/RegisterReplacedView/TriggerReload - Non-functional - Empty handler stubs, no actual reload happens
However, one piece is genuinely needed: IReplaceableView.ReplacedView is used by MVU in ElementExtensions.ToHandler/ToPlatform() for collapsing the view tree.
Additionally, BlazorWebView has a completely separate MetadataUpdateHandler for CSS/JS hot reload that should NOT be removed.
Current State Assessment
HotReload Infrastructure
Located in src/Core/src/HotReload/:
| Component | Status | Evidence |
|---|---|---|
IReloadHandler interface |
Unused | Only implementations are platform containers; never called |
IHotReloadableView interface |
Unused | Implemented by View/ContentPage but Reload() is empty |
MauiHotReloadHelper |
Partially used | RegisterHandlers() called during app init; rest is dead code |
| Metadata update entry points | Dead code | UpdateApplication()/ClearCache() - no MetadataUpdateHandler registered |
| View registration system | Dead code | Register/UnRegister dictionary - never populated or used |
[OnHotReload] attribute |
Dead code | Stubs in handler base classes, never invoked |
IReplaceableView.ReplacedView |
NEEDED | Used by MVU for view tree collapsing in ElementExtensions |
Evidence
- No MetadataUpdateHandler: Search for
[assembly: MetadataUpdateHandlerreturns only BlazorWebView result - No registration calls: No callers to
Register/UnRegister/RegisterReplacedView/TriggerReload - Empty implementations: Handler
OnHotReload()methods are empty stubs - All public APIs: All types are in
PublicAPI.Shipped.txtacross 8 platforms
What Actually Works
- Container wiring: Containers still set
ReloadHandleron views (harmless no-op) IReplaceableView.ReplacedView: Used by MVU inElementExtensions.ToHandler()for view collapsing- Lines 62-63:
if (view is IReplaceableView ir) view = ir.ReplacedView;
- Lines 62-63:
Proposed Solution
Phase 1: Deprecation (This Change)
Add [Obsolete] attributes to mark infrastructure as deprecated while maintaining compatibility.
Deprecate these methods/types:
IReloadHandlerinterfaceIHotReloadableViewinterfaceOnHotReloadAttributeHotReloadExtensionsstatic classMauiHotReloadHelpermethods (exceptRegisterHandlers())- Metadata update entry points:
UpdateApplication(),ClearCache()
Keep (but no-op):
IReplaceableView- required for MVUMauiHotReloadHelper.RegisterHandlers()- called during app startup- Container hot reload wiring - harmless if disabled in future
- View/ContentPage implementations - harmless if never called
Remove:
[OnHotReload]attributes from handler base classes (empty stubs)
Files affected (Phase 1):
- 6 HotReload source files (add
[Obsolete]) - 2 handler files (remove
[OnHotReload]) - 8 PublicAPI.Shipped.txt files (update entries)
- Container files (add comments explaining no-op status)
Phase 2: Removal (Future Major Version)
Remove the infrastructure entirely. This would be a breaking change suitable for next major version.
Remove:
- Entire
src/Core/src/HotReload/folder IHotReloadableViewimplementation fromViewandContentPage- Hot reload wiring from platform containers
Simplify:
IReplaceableView- keep onlyReplacedView { get; }property- Minimal implementation in View/ContentPage (just return self by default)
Files to Modify (Phase 1)
Core HotReload
src/Core/src/HotReload/IReloadHandler.cs- Add [Obsolete]src/Core/src/HotReload/IHotReloadableView.cs- Add [Obsolete]src/Core/src/HotReload/OnHotReloadAttribute.cs- Add [Obsolete]src/Core/src/HotReload/HotReloadExtensions.cs- Add [Obsolete]src/Core/src/HotReload/HotReloadHelper.cs- Add [Obsolete] to methods
Handlers
src/Core/src/Handlers/View/ViewHandlerOfT.cs- Remove[OnHotReload]attributesrc/Core/src/Handlers/Element/ElementHandlerOfT.cs- Remove[OnHotReload]attribute
Implementations
src/Controls/src/Core/View/View.cs- Keep implementation, add commentsrc/Controls/src/Core/ContentPage/ContentPage.cs- Keep implementation, add comment
Platforms
src/Core/src/Platform/Android/ContainerView.cs- Add commentsrc/Core/src/Platform/iOS/ContainerViewController.cs- Add commentsrc/Core/src/Platform/Tizen/ContainerView.cs- Add comment
PublicAPI (8 files)
src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/net-windows/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/netstandard/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/netstandard2.0/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txtsrc/Core/src/PublicAPI/net/PublicAPI.Shipped.txt
User Migration Path
Phase 1 (Deprecation)
- Users not using HotReload: No change needed
- Users with custom
[OnHotReload]handlers: Suppress warnings with#pragma disable CS0618or<NoWarn>618</NoWarn>
Phase 2 (Removal)
- Must remove custom HotReload implementations
- Recommend using VS/Rider hot reload or custom tooling instead
- Provide migration guide in release notes
Discussion Points
-
Metadata Update Registration: Should we ever register a MetadataUpdateHandler for View hot reload, or is this infrastructure permanently deprecated?
-
BlazorWebView Exception: Confirmed that
StaticContentHotReloadManagerin BlazorWebView is separate and active (CSS/JS hot reload). This should NOT be removed. -
Phase 1 Timing: Can this deprecation be merged in current release, or should we wait?
-
Phase 2 Timeline: Target for removal (e.g., next major version)?
-
Migration Documentation: Should we provide guidance for users wanting custom hot reload?
Obsolete Message
Suggested message for all deprecated types:
[Obsolete(
"The HotReload infrastructure is deprecated and will be removed in a future version. " +
"Metadata-driven hot reload is not currently supported in MAUI. " +
"For hot reload support, use Visual Studio/Rider hot reload or implement custom solutions. " +
"The IReplaceableView interface will be retained for internal MVU support.",
error: false)]Testing
Phase 1 validation:
- Build succeeds with [Obsolete] attributes
- No compilation errors in core tests
IReplaceableView.ReplacedViewstill works in MVU (ElementExtensions)- Container wiring still executes (no-op)
- Controls sample launches without issues
- All UI tests pass
- BlazorWebView hot reload still works (separate system)
Phase 2 validation (future):
- Code compiles after removing HotReload folder
- All public API tests pass
- Control tests pass
- Sample apps launch successfully