diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs
index e24941de62c7a..a92c8fc231850 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs
@@ -6,13 +6,14 @@
namespace System.Runtime.CompilerServices
{
///
- /// Reserved to be used by the compiler for tracking metadata.
+ /// Reserved for use by a compiler for tracking metadata.
/// This attribute should not be used by developers in source code.
///
[EditorBrowsable(EditorBrowsableState.Never)]
[AttributeUsage(AttributeTargets.Struct)]
public sealed class IsByRefLikeAttribute : Attribute
{
+ /// Initializes the attribute.
public IsByRefLikeAttribute()
{
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs
index 874d11c2a2d31..ec751670562f7 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs
@@ -6,13 +6,14 @@
namespace System.Runtime.CompilerServices
{
///
- /// Reserved to be used by the compiler for tracking metadata.
+ /// Reserved for use by a compiler for tracking metadata.
/// This attribute should not be used by developers in source code.
///
[EditorBrowsable(EditorBrowsableState.Never)]
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public sealed class IsReadOnlyAttribute : Attribute
{
+ /// Initializes the attribute.
public IsReadOnlyAttribute()
{
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsUnmanagedAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsUnmanagedAttribute.cs
index b88bc5ae3b419..f0aeb6d881dc0 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsUnmanagedAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsUnmanagedAttribute.cs
@@ -1,9 +1,21 @@
// 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
{
+ ///
+ /// Reserved for use by a compiler for tracking metadata.
+ /// This attribute should not be used by developers in source code.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.All)]
public sealed class IsUnmanagedAttribute : Attribute
{
+ /// Initializes the attribute.
+ public IsUnmanagedAttribute()
+ {
+ }
}
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableAttribute.cs
index 9290ce368e9c5..8b6e713cadae1 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableAttribute.cs
@@ -1,18 +1,30 @@
// 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
{
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
+ ///
+ /// Reserved for use by a compiler for tracking metadata.
+ /// This attribute should not be used by developers in source code.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
public sealed class NullableAttribute : Attribute
{
+ /// Flags specifying metadata related to nullable reference types.
public readonly byte[] NullableFlags;
+ /// Initializes the attribute.
+ /// The flags value.
public NullableAttribute(byte value)
{
NullableFlags = new[] { value };
}
+ /// Initializes the attribute.
+ /// The flags value.
public NullableAttribute(byte[] value)
{
NullableFlags = value;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableContextAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableContextAttribute.cs
index 579d09b7d4a77..8f4140f2ede33 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableContextAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullableContextAttribute.cs
@@ -1,13 +1,23 @@
// 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
{
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
+ ///
+ /// Reserved for use by a compiler for tracking metadata.
+ /// This attribute should not be used by developers in source code.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
public sealed class NullableContextAttribute : Attribute
{
+ /// Flag specifying metadata related to nullable reference types.
public readonly byte Flag;
+ /// Initializes the attribute.
+ /// The flag value.
public NullableContextAttribute(byte value)
{
Flag = value;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullablePublicOnlyAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullablePublicOnlyAttribute.cs
index 5001666f22a33..7abb7c24d343a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullablePublicOnlyAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/NullablePublicOnlyAttribute.cs
@@ -1,13 +1,23 @@
// 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
{
- [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
+ ///
+ /// Reserved for use by a compiler for tracking metadata.
+ /// This attribute should not be used by developers in source code.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Module, Inherited = false)]
public sealed class NullablePublicOnlyAttribute : Attribute
{
+ /// Indicates whether metadata for internal members is included.
public readonly bool IncludesInternals;
+ /// Initializes the attribute.
+ /// Indicates whether metadata for internal members is included.
public NullablePublicOnlyAttribute(bool value)
{
IncludesInternals = value;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RefSafetyRulesAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RefSafetyRulesAttribute.cs
index 8b6525030c306..1d1173158489d 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RefSafetyRulesAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RefSafetyRulesAttribute.cs
@@ -1,10 +1,13 @@
// 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
{
/// Indicates the language version of the ref safety rules used when the module was compiled.
- [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Module, Inherited = false)]
public sealed class RefSafetyRulesAttribute : Attribute
{
/// Initializes a new instance of the class.
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs
index 4a17cfc290b2a..f03116d2e8522 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs
@@ -1,10 +1,13 @@
// 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
{
/// Specifies that a type has required members or that a member is required.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
#if SYSTEM_PRIVATE_CORELIB
public
#else
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ScopedRefAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ScopedRefAttribute.cs
index a670252535a76..4ca4131779afa 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ScopedRefAttribute.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ScopedRefAttribute.cs
@@ -1,10 +1,21 @@
// 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
{
- [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
+ ///
+ /// Reserved for use by a compiler for tracking metadata.
+ /// This attribute should not be used by developers in source code.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
public sealed class ScopedRefAttribute : Attribute
{
+ /// Initializes the attribute.
+ public ScopedRefAttribute()
+ {
+ }
}
}
diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs
index daf6d38ee5aa6..ec7a2577fc100 100644
--- a/src/libraries/System.Runtime/ref/System.Runtime.cs
+++ b/src/libraries/System.Runtime/ref/System.Runtime.cs
@@ -8283,7 +8283,7 @@ public sealed partial class ExcludeFromCodeCoverageAttribute : System.Attribute
public ExcludeFromCodeCoverageAttribute() { }
public string? Justification { get { throw null; } set { } }
}
- [System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Module | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Delegate, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Module | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Delegate, Inherited = false)]
public sealed class ExperimentalAttribute : System.Attribute
{
public ExperimentalAttribute(string diagnosticId) { }
@@ -8360,7 +8360,7 @@ public RequiresUnreferencedCodeAttribute(string message) { }
public string Message { get { throw null; } }
public string? Url { get { throw null; } set { } }
}
- [System.AttributeUsage(System.AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
public sealed class SetsRequiredMembersAttribute : System.Attribute
{
public SetsRequiredMembersAttribute() { }
@@ -12751,7 +12751,7 @@ public sealed partial class InterpolatedStringHandlerAttribute : System.Attribut
{
public InterpolatedStringHandlerAttribute() { }
}
- [AttributeUsage(System.AttributeTargets.Struct, AllowMultiple = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Struct, AllowMultiple = false)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class InlineArrayAttribute : System.Attribute
{
@@ -12781,6 +12781,8 @@ public partial interface IStrongBox
{
object? Value { get; set; }
}
+ [System.AttributeUsageAttribute(System.AttributeTargets.All)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class IsUnmanagedAttribute : Attribute
{
}
@@ -12837,7 +12839,8 @@ public sealed partial class ModuleInitializerAttribute : System.Attribute
{
public ModuleInitializerAttribute() { }
}
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue | System.AttributeTargets.GenericParameter, Inherited = false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
@@ -12845,13 +12848,15 @@ public NullableAttribute(byte value) { }
public NullableAttribute(byte[] value) { }
}
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Method | System.AttributeTargets.Interface | System.AttributeTargets.Delegate, Inherited = false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte value) { }
}
- [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Module, Inherited = false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class NullablePublicOnlyAttribute : Attribute
{
public readonly bool IncludesInternals;
@@ -12889,13 +12894,15 @@ public sealed partial class PreserveBaseOverridesAttribute : System.Attribute
{
public PreserveBaseOverridesAttribute() { }
}
- [System.AttributeUsage(System.AttributeTargets.Module, AllowMultiple=false, Inherited=false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Module, Inherited=false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class RefSafetyRulesAttribute : System.Attribute
{
public RefSafetyRulesAttribute(int version) { }
public int Version { get { throw null; } }
}
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed class RequiredMemberAttribute : System.Attribute
{
public RequiredMemberAttribute() { }
@@ -12969,7 +12976,8 @@ public RuntimeWrappedException(object thrownObject) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
- [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
+ [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited = false)]
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class ScopedRefAttribute : Attribute
{
}
diff --git a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs
index 67e46579a023b..546742b631c8a 100644
--- a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs
+++ b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs
@@ -192,6 +192,32 @@ public static void MethodImplAttributeTests()
Assert.Equal(MethodImplOptions.Unmanaged, attr3.Value);
}
+ [Fact]
+ public static void NullableAttributeTests()
+ {
+ var attr = new NullableAttribute(42);
+ Assert.Equal(new byte[] { 42 }, attr.NullableFlags);
+
+ attr = new NullableAttribute(new byte[] { 1, 2, 3 });
+ Assert.Equal(new byte[] { 1, 2, 3 }, attr.NullableFlags);
+ }
+
+ [Fact]
+ public static void NullableContextAttributeTests()
+ {
+ var attr = new NullableContextAttribute(42);
+ Assert.Equal(42, attr.Flag);
+ }
+
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public static void NullablePublicOnlyAttributeTests(bool includeInternals)
+ {
+ var attr = new NullablePublicOnlyAttribute(includeInternals);
+ Assert.Equal(includeInternals, attr.IncludesInternals);
+ }
+
[Theory]
[InlineData(-1)]
[InlineData(42)]
@@ -299,6 +325,12 @@ public static void IsReadOnlyAttributeTests()
new IsReadOnlyAttribute();
}
+ [Fact]
+ public static void IsUnmanagedAttributeTests()
+ {
+ new IsUnmanagedAttribute();
+ }
+
[Fact]
public static void EnumeratorCancellationAttributeTests()
{
@@ -336,6 +368,12 @@ public static void RequiredMemberAttributeTests()
new RequiredMemberAttribute();
}
+ [Fact]
+ public static void ScopedRefAttributeTests()
+ {
+ new ScopedRefAttribute();
+ }
+
[Fact]
public static void CompilerFeatureRequiredTests()
{