diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs index c874d3fc1f485f..fdf8ae7965feae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs @@ -10,6 +10,9 @@ namespace System.Runtime.CompilerServices /// Provides an awaitable async enumerable that enables cancelable iteration and configured awaits. [StructLayout(LayoutKind.Auto)] public readonly struct ConfiguredCancelableAsyncEnumerable +#if NET10_0_OR_GREATER + where T : allows ref struct +#endif { private readonly IAsyncEnumerable _enumerable; private readonly CancellationToken _cancellationToken; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.cs index 796080a24e7472..2841a334b23f12 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.cs @@ -22,8 +22,11 @@ public static ConfiguredAsyncDisposable ConfigureAwait(this IAsyncDisposable sou /// to capture and marshal back to the current context; otherwise, . /// The configured enumerable. public static ConfiguredCancelableAsyncEnumerable ConfigureAwait( - this IAsyncEnumerable source, bool continueOnCapturedContext) => - new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext, cancellationToken: default); + this IAsyncEnumerable source, bool continueOnCapturedContext) +#if NET10_0_OR_GREATER + where T : allows ref struct +#endif + => new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext, cancellationToken: default); /// Sets the to be passed to when iterating. /// The type of the objects being iterated. @@ -31,7 +34,10 @@ public static ConfiguredCancelableAsyncEnumerable ConfigureAwait( /// The to use. /// The configured enumerable. public static ConfiguredCancelableAsyncEnumerable WithCancellation( - this IAsyncEnumerable source, CancellationToken cancellationToken) => - new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext: true, cancellationToken); + this IAsyncEnumerable source, CancellationToken cancellationToken) +#if NET10_0_OR_GREATER + where T : allows ref struct +#endif + => new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext: true, cancellationToken); } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 5f8847cf2f4518..0fcc4bd3639540 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -13298,6 +13298,7 @@ public readonly partial struct ConfiguredAsyncDisposable public System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable DisposeAsync() { throw null; } } public readonly partial struct ConfiguredCancelableAsyncEnumerable + where T : allows ref struct { private readonly object _dummy; private readonly int _dummyPrimitive; @@ -15983,10 +15984,10 @@ public static void WaitAll(System.Threading.Tasks.Task[] tasks, System.Threading public static partial class TaskAsyncEnumerableExtensions { public static System.Runtime.CompilerServices.ConfiguredAsyncDisposable ConfigureAwait(this System.IAsyncDisposable source, bool continueOnCapturedContext) { throw null; } - public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable ConfigureAwait(this System.Collections.Generic.IAsyncEnumerable source, bool continueOnCapturedContext) { throw null; } + public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable ConfigureAwait(this System.Collections.Generic.IAsyncEnumerable source, bool continueOnCapturedContext) where T : allows ref struct { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Collections.Generic.IEnumerable ToBlockingEnumerable(this System.Collections.Generic.IAsyncEnumerable source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable WithCancellation(this System.Collections.Generic.IAsyncEnumerable source, System.Threading.CancellationToken cancellationToken) { throw null; } + public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable WithCancellation(this System.Collections.Generic.IAsyncEnumerable source, System.Threading.CancellationToken cancellationToken) where T : allows ref struct { throw null; } } public partial class TaskCanceledException : System.OperationCanceledException {