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 ac793c38fc2767..35ee6e5f18f65b 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
@@ -609,6 +609,7 @@
+
diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs
new file mode 100644
index 00000000000000..fef7f11749863f
--- /dev/null
+++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ ///
+ /// Used to indicate to the compiler that the .locals init flag should
+ /// not be set in nested method headers when emitting to metadata.
+ ///
+ ///
+ /// This attribute is unsafe because it may reveal uninitialized memory to
+ /// the application in certain instances (e.g., reading from uninitialized
+ /// stackalloc'd memory). If applied to a method directly, the attribute
+ /// applies to that method and all nested functions (lambdas, local
+ /// functions) below it. If applied to a type or module, it applies to all
+ /// methods nested inside. This attribute is intentionally not permitted on
+ /// assemblies. Use at the module level instead to apply to multiple type
+ /// declarations.
+ ///
+ [AttributeUsage(AttributeTargets.Module
+ | AttributeTargets.Class
+ | AttributeTargets.Struct
+ | AttributeTargets.Constructor
+ | AttributeTargets.Method
+ | AttributeTargets.Property
+ | AttributeTargets.Event, Inherited = false)]
+ public sealed class SkipLocalsInitAttribute : Attribute
+ {
+ public SkipLocalsInitAttribute()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs
index d203dcc3d17be3..2caba78c09e26c 100644
--- a/src/libraries/System.Runtime/ref/System.Runtime.cs
+++ b/src/libraries/System.Runtime/ref/System.Runtime.cs
@@ -6914,6 +6914,11 @@ public RuntimeWrappedException(object thrownObject) { }
public object WrappedException { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
+ [System.AttributeUsageAttribute(System.AttributeTargets.Module | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false)]
+ public sealed partial class SkipLocalsInitAttribute : System.Attribute
+ {
+ public SkipLocalsInitAttribute() { }
+ }
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct)]
public sealed partial class SpecialNameAttribute : 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 66ba84f4353797..0ee7a7a723258f 100644
--- a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs
+++ b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/AttributesTests.cs
@@ -8,6 +8,12 @@ namespace System.Runtime.CompilerServices.Tests
{
public static class AttributesTests
{
+ [Fact]
+ public static void SkipLocalsInitAttributeTests()
+ {
+ new SkipLocalsInitAttribute();
+ }
+
[Fact]
public static void AccessedThroughPropertyAttributeTests()
{