Skip to content

Commit 05a1d36

Browse files
Merge pull request #34 from Open-NET-Libraries/v7-update
V7 update
2 parents 0bd9c47 + 7e7124d commit 05a1d36

13 files changed

Lines changed: 59 additions & 58 deletions

Open.ChannelExtensions.ComparisonTests/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ await Enumerable
106106
Console.WriteLine();
107107
}
108108

109-
#if NETCOREAPP3_0
110109
{
111110
Console.WriteLine("Async Enumerable test...");
112111
var sw = Stopwatch.StartNew();
@@ -120,7 +119,6 @@ await Enumerable
120119
Console.WriteLine(sw.Elapsed);
121120
Console.WriteLine();
122121
}
123-
#endif
124122

125123
}
126124

Open.ChannelExtensions.Tests/AssumptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static async Task WaitCancellation()
1010
{
1111
CancellationToken token = tokenSource.Token;
1212

13-
var t = channel.Reader.WaitToReadAsync(token).ConfigureAwait(false);
13+
var t = channel.Reader.WaitToReadAsync(token);
1414
tokenSource.Cancel();
1515

1616
// NOTE: a cancelled WaitToReadAsync will throw.
@@ -26,7 +26,7 @@ public static async Task WaitCancellation()
2626
tokenSource.Cancel();
2727

2828
// NOTE: a cancelled WhenAny will not throw!
29-
var result = await Task.WhenAny(t1.AsTask(), t2.AsTask()).ConfigureAwait(false);
29+
var result = await Task.WhenAny(t1.AsTask(), t2.AsTask());
3030
Assert.True(result.IsCanceled);
3131
}
3232
}

Open.ChannelExtensions.Tests/BatchTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ public static async Task TimeoutTest1()
259259
}));
260260
}
261261

262-
#if NET5_0_OR_GREATER
263262
[Fact]
264263
public static async Task BatchReadBehavior()
265264
{
@@ -362,7 +361,7 @@ public static async Task ReadBatchWithTimeoutEnumerableBakedIn()
362361
Debug.WriteLine("First batch received: " + string.Join(',', batch.Select(item => item)));
363362
break;
364363
case 1:
365-
Assert.Equal(1, batch.Count);
364+
Assert.Single(batch);
366365
Assert.Equal(3, batch[0]);
367366
Debug.WriteLine("Second batch received: " + string.Join(',', batch.Select(item => item)));
368367
break;
@@ -408,5 +407,4 @@ public static async IAsyncEnumerable<IList<T>> ReadBatchEnumerableAsyncBakedIn<T
408407
if (item?.Count > 0) yield return item;
409408
}
410409
}
411-
#endif
412410
}

Open.ChannelExtensions.Tests/SpecialTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public void PossibleSourceLoadingIssue()
2121

2222
queue.CompleteAdding();
2323

24+
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
2425
processingTask.Wait();
26+
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
2527

2628
Assert.Equal(expectedCount, count_);
2729

Open.ChannelExtensions/BatchingChannelReader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected BatchingChannelReader(
3939
Timer? _timer;
4040

4141
/// <summary>
42-
/// Specifies a timeout by which a batch will be emmited there is at least one item but has been waiting
42+
/// Specifies a timeout by which a batch will be emitted there is at least one item but has been waiting
4343
/// for longer than the timeout value.
4444
/// </summary>
4545
/// <param name="millisecondsTimeout">
@@ -151,7 +151,7 @@ protected override bool TryPipeItems(bool flush)
151151
{
152152
if (c is null)
153153
{
154-
newBatch = true; // a new batch could start but not be emmited.
154+
newBatch = true; // a new batch could start but not be emitted.
155155
_batch = c = CreateBatch(_batchSize);
156156
AddBatchItem(c, item);
157157
}
@@ -195,7 +195,7 @@ void Emit(ref TBatch? c)
195195
{
196196
_batch = null;
197197
newBatch = false;
198-
if (!batched) TryUpdateTimer(Timeout.Infinite); // Since we're emmitting one, let's ensure the timeout is cancelled.
198+
if (!batched) TryUpdateTimer(Timeout.Infinite); // Since we're emitting one, let's ensure the timeout is cancelled.
199199
batched = Buffer!.Writer.TryWrite(c!);
200200
Debug.Assert(batched);
201201
c = null;

Open.ChannelExtensions/Extensions.Read.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
423423
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
424424
/// <returns>The count of items read after the reader has completed.
425425
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
426-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
426+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
427427
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
428428
CancellationToken cancellationToken,
429429
Func<T, long, ValueTask> receiver,
@@ -480,7 +480,7 @@ public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, T
480480
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
481481
/// <returns>The count of items read after the reader has completed.
482482
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
483-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
483+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
484484
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
485485
CancellationToken cancellationToken,
486486
Func<TRead, long, ValueTask> receiver,
@@ -532,7 +532,7 @@ public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrit
532532
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
533533
/// <returns>The count of items read after the reader has completed.
534534
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
535-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
535+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
536536
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
537537
CancellationToken cancellationToken,
538538
Func<TRead, long, Task> receiver,
@@ -581,7 +581,7 @@ public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
581581
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
582582
/// <returns>The count of items read after the reader has completed.
583583
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
584-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
584+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
585585
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader,
586586
CancellationToken cancellationToken,
587587
Func<T, ValueTask> receiver,
@@ -630,7 +630,7 @@ public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader,
630630
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
631631
/// <returns>The count of items read after the reader has completed.
632632
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
633-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
633+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
634634
public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader,
635635
CancellationToken cancellationToken,
636636
Func<T, Task> receiver,
@@ -682,7 +682,7 @@ public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrit
682682
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
683683
/// <returns>The count of items read after the reader has completed.
684684
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
685-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
685+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
686686
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
687687
CancellationToken cancellationToken,
688688
Func<TRead, Task> receiver,
@@ -740,7 +740,7 @@ public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, T
740740
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
741741
/// <returns>The count of items read after the reader has completed.
742742
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
743-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
743+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
744744
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
745745
CancellationToken cancellationToken,
746746
Func<TRead, ValueTask> receiver,
@@ -753,7 +753,7 @@ public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, T
753753
/// <typeparam name="T">The item type.</typeparam>
754754
/// <param name="reader">The channel reader to read from.</param>
755755
/// <param name="receiver">The receiver function.</param>
756-
/// <param name="deferredExecution">If true, calls await Task.Yield() before writreadinging.</param>
756+
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
757757
/// <param name="cancellationToken">An optional cancellation token.</param>
758758
/// <returns>The count of items read after the reader has completed.
759759
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
@@ -783,7 +783,7 @@ public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
783783
/// <param name="reader">The channel reader to read from.</param>
784784
/// <param name="receiver">The receiver function.</param>
785785
/// <param name="cancellationToken">The cancellation token.</param>
786-
/// <param name="deferredExecution">If true, calls await Task.Yield() before writreadinging.</param>
786+
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
787787
/// <returns>The count of items read after the reader has completed.
788788
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
789789
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
@@ -799,10 +799,10 @@ public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
799799
/// <param name="reader">The channel reader to read from.</param>
800800
/// <param name="cancellationToken">The cancellation token.</param>
801801
/// <param name="receiver">The receiver function.</param>
802-
/// <param name="deferredExecution">If true, calls await Task.Yield() before writreadinging.</param>
802+
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
803803
/// <returns>The count of items read after the reader has completed.
804804
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
805-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
805+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
806806
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
807807
CancellationToken cancellationToken,
808808
Action<T, long> receiver,
@@ -860,7 +860,7 @@ public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead>
860860
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
861861
/// <returns>The count of items read after the reader has completed.
862862
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
863-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
863+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
864864
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel,
865865
CancellationToken cancellationToken,
866866
Action<TRead, long> receiver,
@@ -921,7 +921,7 @@ public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
921921
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
922922
/// <returns>The count of items read after the reader has completed.
923923
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
924-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
924+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
925925
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader,
926926
CancellationToken cancellationToken,
927927
Action<T> receiver,
@@ -978,7 +978,7 @@ public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead>
978978
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
979979
/// <returns>The count of items read after the reader has completed.
980980
/// The count should be ignored if the number of iterations could exceed the max value of long.</returns>
981-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
981+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
982982
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel,
983983
CancellationToken cancellationToken,
984984
Action<TRead> receiver,
@@ -1020,7 +1020,7 @@ public static ValueTask<long> ReadAllAsLines(this ChannelReader<string> reader,
10201020
/// </summary>
10211021
/// <typeparam name="T">The item type.</typeparam>
10221022
/// <param name="channel">The channel to read from.</param>
1023-
/// <param name="receiver">The TextWriter to recieve the lines.</param>
1023+
/// <param name="receiver">The TextWriter to receive the lines.</param>
10241024
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
10251025
/// <param name="cancellationToken">An optional cancellation token.</param>
10261026
/// <returns>The count of items read after the reader has completed.
@@ -1041,7 +1041,7 @@ public static ValueTask<long> ReadAllAsLines<T>(this Channel<T, string> channel,
10411041
/// </summary>
10421042
/// <typeparam name="T">The item type.</typeparam>
10431043
/// <param name="channel">The channel to read from.</param>
1044-
/// <param name="receiver">The TextWriter to recieve the lines.</param>
1044+
/// <param name="receiver">The TextWriter to receive the lines.</param>
10451045
/// <param name="cancellationToken">An optional cancellation token.</param>
10461046
/// <param name="deferredExecution">If true, calls await Task.Yield() before reading.</param>
10471047
/// <returns>The count of items read after the reader has completed.

Open.ChannelExtensions/Extensions.ReadConcurrently.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async Task<long> Read()
7979
/// <param name="cancellationToken">The cancellation token.</param>
8080
/// <param name="receiver">The async receiver function.</param>
8181
/// <returns>A task that completes when no more reading is to be done.</returns>
82-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
82+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
8383
public static Task<long> ReadAllConcurrentlyAsync<T>(this ChannelReader<T> reader,
8484
int maxConcurrency,
8585
CancellationToken cancellationToken,
@@ -132,7 +132,7 @@ public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TW
132132
/// <param name="cancellationToken">The cancellation token.</param>
133133
/// <param name="receiver">The async receiver function.</param>
134134
/// <returns>A task that completes when no more reading is to be done.</returns>
135-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
135+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
136136
public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel,
137137
int maxConcurrency,
138138
CancellationToken cancellationToken,
@@ -190,7 +190,7 @@ public static Task<long> ReadAllConcurrently<T>(this ChannelReader<T> reader,
190190
/// <param name="cancellationToken">The cancellation token.</param>
191191
/// <param name="receiver">The receiver function.</param>
192192
/// <returns>A task that completes when no more reading is to be done.</returns>
193-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
193+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
194194
public static Task<long> ReadAllConcurrently<T>(this ChannelReader<T> reader,
195195
int maxConcurrency,
196196
CancellationToken cancellationToken,
@@ -228,7 +228,7 @@ public static Task<long> ReadAllConcurrently<TWrite, TRead>(this Channel<TWrite,
228228
/// <param name="cancellationToken">The cancellation token.</param>
229229
/// <param name="receiver">The receiver function.</param>
230230
/// <returns>A task that completes when no more reading is to be done.</returns>
231-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
231+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
232232
public static Task<long> ReadAllConcurrently<TWrite, TRead>(this Channel<TWrite, TRead> channel,
233233
int maxConcurrency,
234234
CancellationToken cancellationToken,
@@ -300,7 +300,7 @@ async Task Read()
300300
}
301301

302302
/// <inheritdoc cref="ReadAllAsEnumerablesAsync{T}(ChannelReader{T}, Func{IEnumerable{T}, ValueTask}, bool, CancellationToken)"/>
303-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
303+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
304304
public static Task ReadAllConcurrentlyAsEnumerablesAsync<T>(this ChannelReader<T> reader,
305305
int maxConcurrency,
306306
CancellationToken cancellationToken,
@@ -327,7 +327,7 @@ public static Task ReadAllConcurrentlyAsEnumerables<T>(this ChannelReader<T> rea
327327
}
328328

329329
/// <inheritdoc cref="ReadAllAsEnumerablesAsync{T}(ChannelReader{T}, Func{IEnumerable{T}, ValueTask}, bool, CancellationToken)"/>
330-
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convience.")]
330+
[SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "Provided for aesthetic convenience.")]
331331
public static Task ReadAllConcurrentlyAsEnumerables<T>(this ChannelReader<T> reader,
332332
int maxConcurrency,
333333
CancellationToken cancellationToken,

Open.ChannelExtensions/Extensions.Source.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ public static ChannelReader<T> Source<T>(
255255
CancellationToken cancellationToken)
256256
=> Source(target, source, out _, false, cancellationToken);
257257

258-
#if NETSTANDARD2_1
258+
#if NETSTANDARD2_0
259+
#else
259260
/// <inheritdoc cref="SourceAsync{TWrite, TRead}(Channel{TWrite, TRead}, IEnumerable{ValueTask{TWrite}}, out ValueTask{long}, bool, CancellationToken)"/>
260261
public static ChannelReader<TRead> Source<TWrite, TRead>(
261262
this Channel<TWrite, TRead> target,

0 commit comments

Comments
 (0)