From 494c89e9e6e5802b0b2b24a973cf148adcda1505 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 24 Jul 2026 12:17:34 +0000
Subject: [PATCH 1/3] Document ECMA-335 augment III.1.7.7 recognition for ref
attributes
---
.../UnscopedRefAttribute.xml | 11 ++++++++++-
.../RefSafetyRulesAttribute.xml | 12 +++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
index cc51f6d2eee..1189ab11eac 100644
--- a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
+++ b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
@@ -37,7 +37,16 @@
parameters.
This attribute is used in those instances where the should be allowed to escape.
- Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for API authors to understand the lifetime implications of applying this attribute and how it may impact their users.
+ Applying this attribute, in any form, has impact on consumers of the applicable API. It's necessary for API authors to understand the lifetime implications of applying this attribute and how it might impact their users.
+
diff --git a/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml b/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
index 48ded811b5d..7047799871f 100644
--- a/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
+++ b/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
@@ -28,7 +28,17 @@
Indicates the language version of the ref safety rules used when the module was compiled.
- To be added.
+
+
+
From 00015842d094c076e5ded5b9e2ab21ff2d2a530f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 24 Jul 2026 12:24:40 +0000
Subject: [PATCH 2/3] Refine dynamic IL note; UnscopedRef depends on
RefSafetyRules on module
---
xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml | 2 +-
xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
index 1189ab11eac..5e6c368a3a5 100644
--- a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
+++ b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
@@ -44,7 +44,7 @@
This attribute is specially recognized by the runtime. ECMA-335 augment III.1.7.7 defines restrictions on valid IL that reference this attribute. For example, when this attribute is applied to an instance method of a value type, the `this` argument is allowed to escape the method. When the attribute is absent, an optimizing compiler can rely on `this` not escaping to further optimize certain code patterns, such as eliminating boxing. For more information, see the [ECMA-335 CLI Specification Addendum](https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#iii177-opt-in-restrictions), Sec. III.1.7.7 ("Opt-in restrictions").
-Because the runtime relies on this attribute, it can't be stripped from an assembly. Tools that emit IL dynamically must apply this attribute where appropriate so that the emitted IL remains valid.
+Because the runtime relies on this attribute, it can't be stripped from an assembly. The restrictions defined by augment III.1.7.7 apply only when the is present on the module, so this attribute has its documented effect only in a module that's also annotated with `RefSafetyRulesAttribute`. Tools that emit IL dynamically must apply both this attribute and `RefSafetyRulesAttribute` where appropriate so that the emitted IL remains valid.
]]>
diff --git a/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml b/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
index 7047799871f..279be7b1384 100644
--- a/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
+++ b/xml/System.Runtime.CompilerServices/RefSafetyRulesAttribute.xml
@@ -35,7 +35,7 @@
This attribute is specially recognized by the runtime. ECMA-335 augment III.1.7.7 defines restrictions on valid IL that reference this attribute. Applying this attribute to a module opts the module into further restrictions based on the version value specified in the attribute, which permits an optimizing compiler to further optimize certain code patterns. For more information, see the [ECMA-335 CLI Specification Addendum](https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#iii177-opt-in-restrictions), Sec. III.1.7.7 ("Opt-in restrictions").
-Because the runtime relies on this attribute, it can't be stripped from an assembly. Tools that emit IL dynamically must apply this attribute where appropriate so that the emitted IL remains valid.
+Because the runtime relies on this attribute, it can't be stripped from an assembly.
]]>
From df930d7d28963c2c23eb4e97b95be2e3fce2884f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 24 Jul 2026 12:29:53 +0000
Subject: [PATCH 3/3] Drop claim that tools must emit RefSafetyRulesAttribute
---
xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
index 5e6c368a3a5..649bfa10f40 100644
--- a/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
+++ b/xml/System.Diagnostics.CodeAnalysis/UnscopedRefAttribute.xml
@@ -44,7 +44,7 @@
This attribute is specially recognized by the runtime. ECMA-335 augment III.1.7.7 defines restrictions on valid IL that reference this attribute. For example, when this attribute is applied to an instance method of a value type, the `this` argument is allowed to escape the method. When the attribute is absent, an optimizing compiler can rely on `this` not escaping to further optimize certain code patterns, such as eliminating boxing. For more information, see the [ECMA-335 CLI Specification Addendum](https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#iii177-opt-in-restrictions), Sec. III.1.7.7 ("Opt-in restrictions").
-Because the runtime relies on this attribute, it can't be stripped from an assembly. The restrictions defined by augment III.1.7.7 apply only when the is present on the module, so this attribute has its documented effect only in a module that's also annotated with `RefSafetyRulesAttribute`. Tools that emit IL dynamically must apply both this attribute and `RefSafetyRulesAttribute` where appropriate so that the emitted IL remains valid.
+Because the runtime relies on this attribute, it can't be stripped from an assembly. The restrictions defined by augment III.1.7.7 apply only when the is present on the module, so this attribute has its documented effect only in a module that's also annotated with `RefSafetyRulesAttribute`.
]]>