File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1074,4 +1074,25 @@ public static async ValueTask<List<T>> ToListAsync<T>(this ChannelReader<T> read
10741074 await ReadAll ( reader , list . Add ) . ConfigureAwait ( false ) ;
10751075 return list ;
10761076 }
1077+
1078+ #if NETSTANDARD2_0
1079+ /// <summary>
1080+ /// Creates an <see cref="IAsyncEnumerable{T}"/> that enables reading all of the data from the channel.
1081+ /// </summary>
1082+ /// <remarks>Polyfill for netstandard2.0 where the built-in instance method is not available.</remarks>
1083+ public static async IAsyncEnumerable < T > ReadAllAsync < T > (
1084+ this ChannelReader < T > reader ,
1085+ [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
1086+ {
1087+ if ( reader is null ) throw new ArgumentNullException ( nameof ( reader ) ) ;
1088+
1089+ while ( await reader . WaitToReadAsync ( cancellationToken ) . ConfigureAwait ( false ) )
1090+ {
1091+ while ( reader . TryRead ( out T ? item ) )
1092+ {
1093+ yield return item ;
1094+ }
1095+ }
1096+ }
1097+ #endif
10771098}
Original file line number Diff line number Diff line change 2222 <RepositoryType >git</RepositoryType >
2323 <GeneratePackageOnBuild >true</GeneratePackageOnBuild >
2424 <GenerateDocumentationFile >true</GenerateDocumentationFile >
25- <Version >9.2 .0</Version >
25+ <Version >9.3 .0</Version >
2626 <PackageReleaseNotes >Lowered .NET Standard 2.0/2.1 dependency versions to 6.0.0 to reduce minimum requirements for consumers.</PackageReleaseNotes >
2727 <PackageLicenseExpression >MIT</PackageLicenseExpression >
2828 <PublishRepositoryUrl >true</PublishRepositoryUrl >
You can’t perform that action at this time.
0 commit comments