Expose the RequiresLocationAttribute (#89870)
authorTanner Gooding <tagoo@outlook.com>
Fri, 11 Aug 2023 02:10:11 +0000 (19:10 -0700)
committerGitHub <noreply@github.com>
Fri, 11 Aug 2023 02:10:11 +0000 (22:10 -0400)
* Expose the RequiresLocationAttribute

* Add a basic test for RequiresLocationAttribute

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiresLocationAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime/ref/System.Runtime.cs
src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs

index 26d78479c72d8aa35e0e36be5b1eb0ef5b9ba5b3..8e58e09da35d3065a0223c808d89367774e3119d 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PreserveBaseOverridesAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RefSafetyRulesAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RequiredMemberAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RequiresLocationAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeCompatibilityAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeFeature.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeFeature.NonNativeAot.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiresLocationAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiresLocationAttribute.cs
new file mode 100644 (file)
index 0000000..f6af0d7
--- /dev/null
@@ -0,0 +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
+{
+    /// <summary>
+    /// Reserved for use by a compiler for tracking metadata.
+    /// This attribute should not be used by developers in source code.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
+    public sealed class RequiresLocationAttribute : Attribute
+    {
+        /// <summary>Initializes the attribute.</summary>
+        public RequiresLocationAttribute()
+        {
+        }
+    }
+}
index 247730371d03f9bdda343797c913d14291cd5319..900040db349efea53cdda9422cd0ded3f7045799 100644 (file)
@@ -13046,6 +13046,12 @@ namespace System.Runtime.CompilerServices
     {
         public RequiredMemberAttribute() { }
     }
+    [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)]
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+    public sealed partial class RequiresLocationAttribute : System.Attribute
+    {
+        public RequiresLocationAttribute() { }
+    }
     [System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false)]
     public sealed partial class ReferenceAssemblyAttribute : System.Attribute
     {
index e190690254e03643608925e76bc33e672995c499..6f58cc48e5bfb9f54a8e33b953b4a12a69948c43 100644 (file)
@@ -393,5 +393,11 @@ namespace System.Runtime.CompilerServices.Tests
             Assert.Equal("feature2", attr2.FeatureName);
             Assert.True(attr2.IsOptional);
         }
+
+        [Fact]
+        public static void RequiresLocationAttributeTests()
+        {
+            new RequiresLocationAttribute();
+        }
     }
 }