-
Notifications
You must be signed in to change notification settings - Fork 4k
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 an attribute specifying the original type, when we create a diff of a ReloadableType #59954
Comments
Should it be the original type, or the previous type? if I make two successive edits, should it go
Other comments:
|
It should all reference back to the original type. |
If we call the attribute |
Related: #55651 |
Runtime API proposal dotnet/runtime#66222 Edit: I like |
@tmat I had a wacky idea while I was working on the API proposal:
This is pretty terrible and we don't want it, right? |
Seems a bit obscure and too complicated. |
The API proposal was approved. Runtime PR is in dotnet/runtime#69751 I would expect it to be in net7 preview 6 namespace System.Runtime.CompilerServices;
[AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct,
AllowMultiple=false, Inherited=false)]
public class MetadataUpdateOriginalTypeAttribute : Attribute
{
/// <summary> This attribute is emited by Roslyn when a type that is marked with (or derives
/// from a type that is marked with) <see
/// cref="System.Runtime.CompilerServices.CreateNewOnMetadataUpdateAttribute" /> is updated
/// during a hot reload session. The <see cref="OriginalType" /> points to the original version
/// of the updated type. The next update of the type will have the same <see
/// cref="OriginalType" />. Frameworks that provide support for hot reload by implementing a
/// <see cref="System.Reflection.Metadata.MetadataUpdateHandlerAttribute" /> may use this
/// attribute to relate an updated type to its original version. </summary>
///
/// <param name="originalType">The original type that was updated</param>
public MetadataUpdateOriginalTypeAttribute(Type originalType) => OriginalType = originalType;
/// Gets the original version of the type that this attribtue is attached to.
public Type OriginalType { get; }
} |
Background and Motivation
C# Hot Reload added a new
CreateNewOnMetadataUpdateAttribute
attribute, which creates a new type without any limitations. This will be heavily used in Comet. When the new types are sent to the Framework, we need a way to identify the original type it is replacing.Proposed API
Let's add an attribute to the new generated types that will specify the original type it is replacing. This will be automatically applied during the diff creation.
[OriginalType(string fullName)]
Now at runtime, a library framework can check which type is being replaced, by querying the attribute.
The text was updated successfully, but these errors were encountered: