未验证 提交 cfcf99c7 编写于 作者: A Aleksey Kliger (λgeek) 提交者: GitHub

Add MetadataUpdateOriginalTypeAttribute (#69751)

Fixes https://github.com/dotnet/runtime/issues/66222
上级 62f5d4e6
......@@ -761,6 +761,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\MethodImplAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\MethodImplOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ModuleInitializerAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\MetadataUpdateOriginalTypeAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ReferenceAssemblyAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs" />
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
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; }
}
......@@ -30,6 +30,13 @@ namespace System.Runtime.CompilerServices
public sealed class CreateNewOnMetadataUpdateAttribute : System.Attribute
{
}
[AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct,
AllowMultiple=false, Inherited=false)]
public class MetadataUpdateOriginalTypeAttribute : Attribute
{
public MetadataUpdateOriginalTypeAttribute(Type originalType) { throw null; }
public Type OriginalType { get { throw null; } }
}
}
namespace System.Runtime.Loader
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册