From 678fd6a73756f8438be115898cdd4fe0500e3d18 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 10 Aug 2023 19:10:11 -0700 Subject: [PATCH] Expose the RequiresLocationAttribute (#89870) * Expose the RequiresLocationAttribute * Add a basic test for RequiresLocationAttribute --- .../src/System.Private.CoreLib.Shared.projitems | 1 + .../CompilerServices/RequiresLocationAttribute.cs | 21 +++++++++++++++++++++ src/libraries/System.Runtime/ref/System.Runtime.cs | 6 ++++++ .../Runtime/CompilerServices/AttributesTests.cs | 6 ++++++ 4 files changed, 34 insertions(+) create mode 100644 src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiresLocationAttribute.cs diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 26d7847..8e58e09 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -845,6 +845,7 @@ + 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 index 0000000..f6af0d7 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiresLocationAttribute.cs @@ -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 +{ + /// + /// 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 RequiresLocationAttribute : Attribute + { + /// Initializes the attribute. + public RequiresLocationAttribute() + { + } + } +} diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 2477303..900040d 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -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 { 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 e190690..6f58cc4 100644 --- a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs +++ b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs @@ -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(); + } } } -- 2.7.4