@@ -41,12 +41,16 @@ public static partial class ParallelAsync
4141 /// Setting this value to low, will mean a too small list will be allocated and you will have to pay a small performance hit for the resizing of the list during execution.
4242 /// </para>
4343 /// </remarks>
44- public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IEnumerable < TIn > collection , Func < TIn , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
44+ public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IEnumerable < TIn > collection , Func < TIn , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , CancellationToken cancellationToken = default )
4545 {
46+ #if NET8_0_OR_GREATER
47+ ArgumentNullException . ThrowIfNull ( func ) ;
48+ #else
4649 if ( func == null )
4750 {
4851 throw new ArgumentNullException ( nameof ( func ) ) ;
4952 }
53+ #endif //NET8_0_OR_GREATER
5054
5155 var funcWithCancellationToken = WrapFunc ( func ) ;
5256 return ForEachAsyncStream < TResult , TIn > ( collection , funcWithCancellationToken , maxBatchSize , allowOutOfOrderProcessing , estimatedResultSize , cancellationToken ) ;
@@ -80,8 +84,12 @@ public static IAsyncEnumerable<TResult> ForEachAsyncStream<TResult, TIn>(IEnumer
8084 /// Setting this value to low, will mean a too small list will be allocated and you will have to pay a small performance hit for the resizing of the list during execution.
8185 /// </para>
8286 /// </remarks>
83- public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IEnumerable < TIn > collection , Func < TIn , CancellationToken , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
87+ public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IEnumerable < TIn > collection , Func < TIn , CancellationToken , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , CancellationToken cancellationToken = default )
8488 {
89+ #if NET8_0_OR_GREATER
90+ ArgumentNullException . ThrowIfNull ( collection ) ;
91+ ArgumentNullException . ThrowIfNull ( func ) ;
92+ #else
8593 if ( collection == null )
8694 {
8795 throw new ArgumentNullException ( nameof ( collection ) ) ;
@@ -91,6 +99,7 @@ public static IAsyncEnumerable<TResult> ForEachAsyncStream<TResult, TIn>(IEnumer
9199 {
92100 throw new ArgumentNullException ( nameof ( func ) ) ;
93101 }
102+ #endif //NET8_0_OR_GREATER
94103
95104 var maxBatchSizeToUse = DetermineBatchSizeToUse ( maxBatchSize ) ;
96105
@@ -319,12 +328,16 @@ private static async IAsyncEnumerable<TResult> ForEachAsyncStreamImplUnordered<T
319328 /// Setting this value to low, will mean a too small list will be allocated and you will have to pay a small performance hit for the resizing of the list during execution.
320329 /// </para>
321330 /// </remarks>
322- public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IAsyncEnumerable < TIn > collection , Func < TIn , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
331+ public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IAsyncEnumerable < TIn > collection , Func < TIn , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , CancellationToken cancellationToken = default )
323332 {
333+ #if NET8_0_OR_GREATER
334+ ArgumentNullException . ThrowIfNull ( func ) ;
335+ #else
324336 if ( func == null )
325337 {
326338 throw new ArgumentNullException ( nameof ( func ) ) ;
327339 }
340+ #endif //NET8_0_OR_GREATER
328341
329342 var funcWithCancellationToken = WrapFunc ( func ) ;
330343 return ForEachAsyncStream < TResult , TIn > ( collection , funcWithCancellationToken , maxBatchSize , allowOutOfOrderProcessing , estimatedResultSize , cancellationToken ) ;
@@ -358,8 +371,12 @@ public static IAsyncEnumerable<TResult> ForEachAsyncStream<TResult, TIn>(IAsyncE
358371 /// Setting this value to low, will mean a too small list will be allocated and you will have to pay a small performance hit for the resizing of the list during execution.
359372 /// </para>
360373 /// </remarks>
361- public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IAsyncEnumerable < TIn > collection , Func < TIn , CancellationToken , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
374+ public static IAsyncEnumerable < TResult > ForEachAsyncStream < TResult , TIn > ( IAsyncEnumerable < TIn > collection , Func < TIn , CancellationToken , Task < TResult > > func , int maxBatchSize = 0 , bool allowOutOfOrderProcessing = false , int estimatedResultSize = 0 , CancellationToken cancellationToken = default )
362375 {
376+ #if NET8_0_OR_GREATER
377+ ArgumentNullException . ThrowIfNull ( collection ) ;
378+ ArgumentNullException . ThrowIfNull ( func ) ;
379+ #else
363380 if ( collection == null )
364381 {
365382 throw new ArgumentNullException ( nameof ( collection ) ) ;
@@ -369,6 +386,7 @@ public static IAsyncEnumerable<TResult> ForEachAsyncStream<TResult, TIn>(IAsyncE
369386 {
370387 throw new ArgumentNullException ( nameof ( func ) ) ;
371388 }
389+ #endif //NET8_0_OR_GREATER
372390
373391 int maxBatchSizeToUse = DetermineBatchSizeToUse ( maxBatchSize ) ;
374392
@@ -555,8 +573,8 @@ private static async IAsyncEnumerable<TResult> ForEachAsyncStreamImplUnorderedAs
555573 ParallelAsyncEventSource . Log . RunStop ( runId ) ;
556574 }
557575
558- #endregion IAsyncEnumerable<T>
576+ #endregion IAsyncEnumerable<T>
559577 }
560578
561579#endif //NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER
562- }
580+ }
0 commit comments