Skip to content

Deprecate and Remove Non-Functional HotReload Infrastructure #34714

@StephaneDelcroix

Description

@StephaneDelcroix

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: MetadataUpdateHandler returns 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.txt across 8 platforms

What Actually Works

  • Container wiring: Containers still set ReloadHandler on views (harmless no-op)
  • IReplaceableView.ReplacedView: Used by MVU in ElementExtensions.ToHandler() for view collapsing
    • Lines 62-63: if (view is IReplaceableView ir) view = ir.ReplacedView;

Proposed Solution

Phase 1: Deprecation (This Change)

Add [Obsolete] attributes to mark infrastructure as deprecated while maintaining compatibility.

Deprecate these methods/types:

  • IReloadHandler interface
  • IHotReloadableView interface
  • OnHotReloadAttribute
  • HotReloadExtensions static class
  • MauiHotReloadHelper methods (except RegisterHandlers())
  • Metadata update entry points: UpdateApplication(), ClearCache()

Keep (but no-op):

  • IReplaceableView - required for MVU
  • MauiHotReloadHelper.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
  • IHotReloadableView implementation from View and ContentPage
  • Hot reload wiring from platform containers

Simplify:

  • IReplaceableView - keep only ReplacedView { 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] attribute
  • src/Core/src/Handlers/Element/ElementHandlerOfT.cs - Remove [OnHotReload] attribute

Implementations

  • src/Controls/src/Core/View/View.cs - Keep implementation, add comment
  • src/Controls/src/Core/ContentPage/ContentPage.cs - Keep implementation, add comment

Platforms

  • src/Core/src/Platform/Android/ContainerView.cs - Add comment
  • src/Core/src/Platform/iOS/ContainerViewController.cs - Add comment
  • src/Core/src/Platform/Tizen/ContainerView.cs - Add comment

PublicAPI (8 files)

  • src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/net-windows/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/netstandard/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
  • src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt
  • src/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 CS0618 or <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

  1. Metadata Update Registration: Should we ever register a MetadataUpdateHandler for View hot reload, or is this infrastructure permanently deprecated?

  2. BlazorWebView Exception: Confirmed that StaticContentHotReloadManager in BlazorWebView is separate and active (CSS/JS hot reload). This should NOT be removed.

  3. Phase 1 Timing: Can this deprecation be merged in current release, or should we wait?

  4. Phase 2 Timeline: Target for removal (e.g., next major version)?

  5. 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.ReplacedView still 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    s/triagedIssue has been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions