Skip to content

internal runtime API to return hot reload capabilities #50111

@lambdageek

Description

@lambdageek

MonoVM and CoreCLR will both support hot reload in .NET 6. However the actual set of supported (non-"rude") edits are different between the runtimes. In future releases the capabilities of both runtimes will evolve. Part of #44806 and #45629

Related roslyn issue: dotnet/roslyn#49010

In a hot reload editing session, the runtime and the Roslyn compiler (mediated by a communication mechanism such as dotnet watch or the Visual Studio debugger) will need to agree on the supported edits.

One approach would be to build into Roslyn the knowledge of the capabilities of each runtime based on the reported runtime version. However in this case it would be difficult to mix compiler and runtime versions. Also if the runtime wants to disable an edit in a servicing release, it would require closely coupling servicing releases of (potentially several) Roslyn versions and the runtime.

Another approach is to expose a new API implemented by the runtime that returns a list of the supported capabilities:

 namespace System.Reflection.Metadata
{
    partial class AssemblyExtensions
    {
        /// Returns a description of the supported System.Reflection.Metadata.AssemblyExtensions.ApplyUpdate edits.
        /// Returns string.Empty if applying updates is not supported by this runtime.
        internal static string GetApplyUpdateCapabilities ();
    }
}

The specific format of the return value would be implementation defined and in practice it would be a contract between the runtimes and Roslyn.

Example of capabilities description

(This is for illustration only and not part of the API definition)

For example the string might be a space separated sequence of tokens from the following set: Baseline, RuntimeEdits, AddDefinitionToExistingType, NewTypeDefinition. The proposal is to represent .NET 5 CoreCLR capabilities as Baseline plus everything that .NET 5 CoreCLR can do minus what .NET 6 MonoVM can do. That is, .NET 5 MonoVM would be represented by the empty set of capabilities, .NET 5 CoreCLR as Baseline plus everything that CoreCLR can do that .NET6 Mono cannot. In future releases, as MonoVM catches up it will start returning AddDefinitionToExistingType (for example). In future releases when one or both runtimes add a new capability, it will be added to the enumeration. In summary:

  • .NET 5 CoreCLR, .NET Framework: "Baseline AddDefinitionToExistingType NewTypeDefinition " (and ... TBD based on Mono capabilities )
  • .NET 6 CoreCLR: .NET 5 + "RuntimeEdits"
  • .NET 5 MonoVM: ""
  • .NET 6 MonoVM: "Baseline RuntimeEdits"

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions