Closed
Description
Followup work to #44806
In .NET 6, Mono method body replacement is implemented to enable dotnet watch
for Blazor WebAssembly projects, and "Apply Code Changes" in VS in .NET for iOS and .NET for Android. The supported hot reload edits are limited just to modifications of method existing method bodies - provided that certain constructs (such as lambdas, await, etc) are not added.
In .NET 7, we will expand the set of supported edits for Mono-based workloads beyond method body replacement, to include modifications to existing types and adding new types, including "reloadable types".
This issue tracks the followup work to improve Mono's hot reload support.
End to end scenarios
- CLI -
dotnet watch
for Blazor WebAssembly projects - VS family "Apply Code Changes"
- F5 (Run with Debugging) for Blazor and .NET MAUI and mobile SDKs #90045
- Ctrl-F5 (Run without Debugging) for Blazor WebAssembly
- Ctrl-F5 for .NET MAUI, and .NET mobile SDKs
Tasks
- Support more edits
- Support adding custom attributes [metadata-update] Add support for deltas with CustomAttributes modifications #52993
- add static fields to existing classes [mono] Hot Reload: initial push to support adding lambdas #63513
- add static and non-instance methods to existing classes [mono] Hot Reload: initial push to support adding lambdas #63513
- adding instance fields to existing classes [mono] Hot Reload: support adding instance fields #63643
- full support for
NewTypeDefinition
capability including new types with fields, methods, properties, events, nested classes and generic parameters. Including reflection support. [mono] Hot Reload: support for reloadable types #66749 - [mbr] hot reload doesn't work on lambda bodies #50249 - support static lambdas (needs add static fields and add static methods for existing classes) [mono] Hot Reload: initial push to support adding lambdas #63513
- Support adding new nested classes, lambdas [mono] Hot Reload: initial push to support adding lambdas #63513
- Debugger support for new edits (excluding adding instance fields) [mono][debugger] Support new hot reload features from runtime #70697
- Support adding async methods [mono] Failing test ApplyUpdateTests.AsyncMethodChanges #79043
- Add tests and implement support for using reflection on added methods, static and instance fields, properties and events in existing classes.
- [EnC] Implement the UpdateParameters capability #56626
- More type system additions (static fields, static methods, virtual method overrides, etc)
- Generics
- Use MetadataUpdateHandlerAttribute to clear Mono's reflection cache Use MetadataUpdateHandlerAttribute to clear Mono's reflection cache #50978
- Implement host startup hook support Add support for host startup hooks to Mono #47462 to allow mobile Ctrl-F5 scenarios to inject hot reload agents
- [hot reload] Update test infrastructure to consume metadata update handler type ids #66513
- Set up additional CI testing
- Tests in dotnet/runtime for Android and iOS
- Tests in xamarin/xamarin-android and xamarin/xamarin-macios for Android and iOS
Out of scope and future work
- Type system modifications beyond what is supported on CoreCLR workloads (basically all the stuff CoreCLR doesn't support, we won't support either)
- Active statements / On-stack replacement
- Object migration
- JIT support
Possible future work
- Collectible ALC support
- Support mixed AOT/interp mode - AOT code would not be allowed to change (easy check - if an AOT image is loaded, don't accept a delta to that assembly. Harder - check whether individual methods are included in the AOT image - is there a use case for this?). Block applying changes to assemblies with loaded AOT images.