This commit is contained in:
Julien Couvreur 2025-07-30 18:56:04 +05:00 committed by GitHub
commit fc3766b0e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 0 deletions

View File

@ -852,6 +852,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\DiscardableAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\EnumeratorCancellationAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ExtensionAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ExtensionMarkerNameAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FixedAddressValueTypeAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FixedBufferAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FormattableStringFactory.cs" />

View File

@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
namespace System.Runtime.CompilerServices
{
/// <summary>
/// This attribute is used to mark extension members and associate them with a specific marker type (which provides detailed information about an extension block and its receiver parameter).
/// This attribute should not be used by developers in source code.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
public sealed class ExtensionMarkerNameAttribute : Attribute
{
/// <summary>Initializes a new instance of the <see cref="ExtensionMarkerNameAttribute"/> class.</summary>
/// <param name="name">The name of the marker type this extension member is associated with.</param>
public ExtensionMarkerNameAttribute(string name)
=> Name = name;
/// <summary>The name of the marker type this extension member is associated with.</summary>
public string Name { get; }
}
}

View File

@ -13495,6 +13495,13 @@ namespace System.Runtime.CompilerServices
{
public ExtensionAttribute() { }
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Delegate, Inherited = false)]
public sealed partial class ExtensionMarkerNameAttribute : System.Attribute
{
public ExtensionMarkerNameAttribute(string name) { }
public string Name { get { throw null; } }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Field)]
public sealed partial class FixedAddressValueTypeAttribute : System.Attribute
{

View File

@ -235,6 +235,15 @@ namespace System.Runtime.CompilerServices.Tests
Assert.Equal(version, attr.Version);
}
[Theory]
[InlineData("1")]
[InlineData("2")]
public static void ExtensionMarkerNameAttributeTests(string name)
{
var attr = new ExtensionMarkerNameAttribute(name);
Assert.Equal(name, attr.Name);
}
[Fact]
public static void ReferenceAssemblyAttributeTests()
{