From d1be1f832a15e98dd52f7bc9f413cc8528cf09de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 15:42:25 +0000 Subject: [PATCH 01/19] Initial plan From bdf2369f55a01ce888cfb9691c6daedd7c666ba9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 15:47:41 +0000 Subject: [PATCH 02/19] Add link to dotnet/roslyn#64811 in Ref Fields documentation Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index a26490f87b71c2..3e9a3cbf0577c6 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -978,7 +978,7 @@ Note that integer values of less than 4 bytes are extended to int32 (not native evaluation stack. ## Ref Fields -To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired. With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. +To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From 11fd35d01c6f261ad7053dc088071e9aa1d0c006 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:36:42 +0000 Subject: [PATCH 03/19] Clarify Span and Span> as future additions Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index 4bccfa85ef1b17..afe8a11f160fe7 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -1,6 +1,6 @@ # Generics parameters of ByRefLike types -Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following examples: +Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/e8dbda9ab73cbba592206084553a08a6791a272d/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): - `Span` – Represents the general case where a ByRefLike type is used as a Generic parameter. This specific case would be desirable for a more efficient Reflection API. - `Span>` – Nested `Span` types would be of benefit in the parsing result of strings. From 79ff1149d530c752b67e2c53acf03f4492f52949 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:42:44 +0000 Subject: [PATCH 04/19] Add link to sunset restricted types proposal Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 3e9a3cbf0577c6..5426d2ae61b196 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -978,7 +978,7 @@ Note that integer values of less than 4 bytes are extended to int32 (not native evaluation stack. ## Ref Fields -To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. +To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811), [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From 18cc4367f4a94c07a9ddd8edc524818b18c80b55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:47:36 +0000 Subject: [PATCH 05/19] Update link to use main branch instead of specific commit Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index afe8a11f160fe7..ba9b51643f634f 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -1,6 +1,6 @@ # Generics parameters of ByRefLike types -Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/e8dbda9ab73cbba592206084553a08a6791a272d/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): +Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): - `Span` – Represents the general case where a ByRefLike type is used as a Generic parameter. This specific case would be desirable for a more efficient Reflection API. - `Span>` – Nested `Span` types would be of benefit in the parsing result of strings. From 2f485d49de59ad61cb5596b9350d49761706088d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:52:44 +0000 Subject: [PATCH 06/19] Add motivating examples and links to ByRefLike types in generics Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/features/byreflike-generics.md | 7 ++++++- docs/design/specs/Ecma-335-Augments.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index ba9b51643f634f..ba3368f63c7f81 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -1,6 +1,11 @@ # Generics parameters of ByRefLike types -Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): +Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following: + +- `Action>` – Enables passing `Span` to delegate-based APIs, allowing for more flexible and performant code patterns. +- `Func>` – Allows returning `Span` from delegate-based callbacks and functional programming patterns. + +The following are potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): - `Span` – Represents the general case where a ByRefLike type is used as a Generic parameter. This specific case would be desirable for a more efficient Reflection API. - `Span>` – Nested `Span` types would be of benefit in the parsing result of strings. diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 5426d2ae61b196..fd7abad31ede91 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -1032,7 +1032,7 @@ Changes to signatures: ## ByRefLike types in generics -ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters, but in order to improve utility certain affordances are required. +ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811), [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types)), but in order to improve utility certain affordances are required. ### II.10.1.7 An additional IL keyword, `byreflike`, is introduced to indicate use of ByRefLike types is permitted. This expands the set of permissible types used by this parameters, but limits the potential instructions that can be used on instances of this generic parameter type. From 10c6563a4bb230075b5b91fc0899596f77cb30b1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:33:59 +0000 Subject: [PATCH 07/19] Swap order of links in Ref Fields section Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index fd7abad31ede91..46aff4e315d58f 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -978,7 +978,7 @@ Note that integer values of less than 4 bytes are extended to int32 (not native evaluation stack. ## Ref Fields -To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811), [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. +To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From ee151236c500c78c753563d85f6ebf6b4657c8ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:34:37 +0000 Subject: [PATCH 08/19] Swap order of links in ByRefLike types in generics section for consistency Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 46aff4e315d58f..788e6db259bcee 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -1032,7 +1032,7 @@ Changes to signatures: ## ByRefLike types in generics -ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters ([dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811), [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types)), but in order to improve utility certain affordances are required. +ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)), but in order to improve utility certain affordances are required. ### II.10.1.7 An additional IL keyword, `byreflike`, is introduced to indicate use of ByRefLike types is permitted. This expands the set of permissible types used by this parameters, but limits the potential instructions that can be used on instances of this generic parameter type. From 6fec24d3af5fb7732db75cd9e5d18fa5f936e611 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:37:59 -0800 Subject: [PATCH 09/19] Update docs/design/specs/Ecma-335-Augments.md --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 788e6db259bcee..dd4a8bbca9cc2f 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -1032,7 +1032,7 @@ Changes to signatures: ## ByRefLike types in generics -ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)), but in order to improve utility certain affordances are required. +ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters, but in order to improve utility certain affordances are required. See [ref struct Generic Parameters](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#ref-struct-generic-parameters) for C# language counterpart. ### II.10.1.7 An additional IL keyword, `byreflike`, is introduced to indicate use of ByRefLike types is permitted. This expands the set of permissible types used by this parameters, but limits the potential instructions that can be used on instances of this generic parameter type. From c70cbe83c9093a3d9e265c151664bdaf926b85d5 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:38:24 -0800 Subject: [PATCH 10/19] Update docs/design/specs/Ecma-335-Augments.md --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index dd4a8bbca9cc2f..4771f9f03b8497 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -1032,7 +1032,7 @@ Changes to signatures: ## ByRefLike types in generics -ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters, but in order to improve utility certain affordances are required. See [ref struct Generic Parameters](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#ref-struct-generic-parameters) for C# language counterpart. +ByRefLike types, defined in C# with the `ref struct` syntax, represent types that cannot escape to the managed heap and must remain on the stack. It is possible for these types to be used as generic parameters, but in order to improve utility certain affordances are required. See [ref struct Generic Parameters](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#ref-struct-generic-parameters) for C# language counterpart. ### II.10.1.7 An additional IL keyword, `byreflike`, is introduced to indicate use of ByRefLike types is permitted. This expands the set of permissible types used by this parameters, but limits the potential instructions that can be used on instances of this generic parameter type. From 6b40b6dc5e56c2c7c64f7965ecd39a4afa975ced Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:44:39 -0800 Subject: [PATCH 11/19] Update docs/design/features/byreflike-generics.md --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index ba3368f63c7f81..b3f8d83ef01865 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -5,7 +5,7 @@ Using ByRefLike types in Generic parameters is possible by building upon support - `Action>` – Enables passing `Span` to delegate-based APIs, allowing for more flexible and performant code patterns. - `Func>` – Allows returning `Span` from delegate-based callbacks and functional programming patterns. -The following are potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context on why these constructs were not enabled by this feature): +The following are potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): - `Span` – Represents the general case where a ByRefLike type is used as a Generic parameter. This specific case would be desirable for a more efficient Reflection API. - `Span>` – Nested `Span` types would be of benefit in the parsing result of strings. From 8d907b60bfd74f49f813538929c30654d97cf188 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:45:15 -0800 Subject: [PATCH 12/19] Update docs/design/features/byreflike-generics.md --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index b3f8d83ef01865..9f2828b220ee9b 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -5,7 +5,7 @@ Using ByRefLike types in Generic parameters is possible by building upon support - `Action>` – Enables passing `Span` to delegate-based APIs, allowing for more flexible and performant code patterns. - `Func>` – Allows returning `Span` from delegate-based callbacks and functional programming patterns. -The following are potential future additions (see [Span<Span<T>> section](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): +The following are potential future additions (see [Span<Span<T>>](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): - `Span` – Represents the general case where a ByRefLike type is used as a Generic parameter. This specific case would be desirable for a more efficient Reflection API. - `Span>` – Nested `Span` types would be of benefit in the parsing result of strings. From 04bbe29be86315b2014a6872038b7f9381df8c76 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:46:49 -0800 Subject: [PATCH 13/19] Update docs/design/specs/Ecma-335-Augments.md --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 4771f9f03b8497..82df617df88587 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -978,7 +978,7 @@ Note that integer values of less than 4 bytes are extended to int32 (not native evaluation stack. ## Ref Fields -To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. Currently their functionality can be approximated by Span fields, but not all types can be converted into Span types simply. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. +To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From 53e41b473f1247354a403f0bad0039f59ae16c6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:48:12 +0000 Subject: [PATCH 14/19] Combine Action/Func examples and add string.Create example Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- docs/design/features/byreflike-generics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index 9f2828b220ee9b..ba97fd56dd7ef2 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -2,8 +2,8 @@ Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following: -- `Action>` – Enables passing `Span` to delegate-based APIs, allowing for more flexible and performant code patterns. -- `Func>` – Allows returning `Span` from delegate-based callbacks and functional programming patterns. +- `Action>`, `Func>` – Enables passing and returning `Span` in delegate-based APIs, allowing for more flexible and performant code patterns. +- `string.Create(int length, TState state, SpanAction action)` – Provides an efficient way to create strings using stack-allocated buffers with ByRefLike types in generic parameters. The following are potential future additions (see [Span<Span<T>>](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): From 32123455447bed812552308cda236d5a3ab20e9a Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:49:50 -0800 Subject: [PATCH 15/19] Update docs/design/features/byreflike-generics.md --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index ba97fd56dd7ef2..bfd8e425a113a5 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -2,7 +2,7 @@ Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following: -- `Action>`, `Func>` – Enables passing and returning `Span` in delegate-based APIs, allowing for more flexible and performant code patterns. +- `Action>`, `Func>` – Enables passing and returning `Span` in delegate-based APIs without requiring custom delegate types. - `string.Create(int length, TState state, SpanAction action)` – Provides an efficient way to create strings using stack-allocated buffers with ByRefLike types in generic parameters. The following are potential future additions (see [Span<Span<T>>](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): From 9b2b4daedc5779981d84fa8dd2a45ab0ad76f2cf Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 14:51:43 -0800 Subject: [PATCH 16/19] Update docs/design/features/byreflike-generics.md --- docs/design/features/byreflike-generics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/features/byreflike-generics.md b/docs/design/features/byreflike-generics.md index bfd8e425a113a5..71efa4188fb7fc 100644 --- a/docs/design/features/byreflike-generics.md +++ b/docs/design/features/byreflike-generics.md @@ -3,7 +3,7 @@ Using ByRefLike types in Generic parameters is possible by building upon support added for `ref` fields. Scenarios that would benefit most from this are those involving `Span`. For example, consider the following: - `Action>`, `Func>` – Enables passing and returning `Span` in delegate-based APIs without requiring custom delegate types. -- `string.Create(int length, TState state, SpanAction action)` – Provides an efficient way to create strings using stack-allocated buffers with ByRefLike types in generic parameters. +- `string.Create(int length, TState state, SpanAction action)` – Provides a safe and efficient way to create strings from span-based state. The following are potential future additions (see [Span<Span<T>>](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/ref-struct-interfaces.md#spanspant) for additional context): From 76b86ce77768e6dadc85ca7cf189889e5f1cb130 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 15:00:16 -0800 Subject: [PATCH 17/19] Update docs/design/specs/Ecma-335-Augments.md --- docs/design/specs/Ecma-335-Augments.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 82df617df88587..4c426cd13e8c7b 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -978,7 +978,9 @@ Note that integer values of less than 4 bytes are extended to int32 (not native evaluation stack. ## Ref Fields -To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. In order to support these scenarios, support for generalizing ByRef fields, and converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs is desired ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types), [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. +To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. See [ref fields](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/low-level-struct-improvements.md#provide-ref-fields-and-scoped) for C# language counterpart. With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. + +ByRef fields can enable converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs in future. See ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types) and [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From 23c5d2329e7d7a56df5afa6f619266a56f2a8d08 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 15:01:32 -0800 Subject: [PATCH 18/19] Update docs/design/specs/Ecma-335-Augments.md --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index 4c426cd13e8c7b..a4dffdda5e03d6 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -980,7 +980,7 @@ evaluation stack. ## Ref Fields To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. See [ref fields](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/low-level-struct-improvements.md#provide-ref-fields-and-scoped) for C# language counterpart. With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. -ByRef fields can enable converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs in future. See ([sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types) and [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811)). +ByRef fields can enable converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs in future. See [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types) and [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811). Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: From 1581b94fd9ae9c5f2bc8af0f94e8fbafb4ca7669 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 26 Jan 2026 15:42:22 -0800 Subject: [PATCH 19/19] Update docs/design/specs/Ecma-335-Augments.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/design/specs/Ecma-335-Augments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design/specs/Ecma-335-Augments.md b/docs/design/specs/Ecma-335-Augments.md index a4dffdda5e03d6..1600e8e19ab6c3 100644 --- a/docs/design/specs/Ecma-335-Augments.md +++ b/docs/design/specs/Ecma-335-Augments.md @@ -980,7 +980,7 @@ evaluation stack. ## Ref Fields To improve the usefulness of ref structs, support for fields which are defined as ByRefs is needed. See [ref fields](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/low-level-struct-improvements.md#provide-ref-fields-and-scoped) for C# language counterpart. With this set of changes, it becomes possible to have ByRef fields of T, but support for pointers to ByRef fields or ByRefs to ByRefs is not added to the ECMA specification. -ByRef fields can enable converting TypedReference, ArgIterator and RuntimeArgumentHandle into following the normal rules of C# ref structs in future. See [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types) and [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811). +ByRef fields can enable converting TypedReference, ArgIterator, and RuntimeArgumentHandle to follow the normal rules of C# ref structs in the future. See [sunset restricted types](https://github.com/dotnet/csharplang/blob/main/proposals/expand-ref.md#sunset-restricted-types) and [dotnet/roslyn#64811](https://github.com/dotnet/roslyn/issues/64811). Changes to the spec. These changes are relative to the 6th edition (June 2012) of the ECMA-335 specification published by ECMA available at: