Skip to content

Commit e17860f

Browse files
Use global usings and futher cleanup.
1 parent bab752b commit e17860f

19 files changed

+67
-156
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,6 @@ dotnet_naming_style.begins_with_i.capitalization = pascal_case
219219

220220
# RCS1123: Add parentheses when necessary.
221221
dotnet_diagnostic.RCS1123.severity = silent
222+
223+
# IDE0290: Don't suggest primary constructor.
224+
dotnet_diagnostic.IDE0290.severity = silent

Open.ChannelExtensions.Tests/CancellationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public static class CancellationTests
66
public static async Task OperationCancellationPropagation()
77
{
88
int count = 0;
9-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, 1000);
9+
IEnumerable<int> range = Enumerable.Range(0, 1000);
1010
using var tokenSource = new CancellationTokenSource();
1111
CancellationToken token = tokenSource.Token;
1212
try
@@ -37,7 +37,7 @@ public static async Task TaskCancellationPropagationConcurrent()
3737
const int testSize = 1000000;
3838
int total = 0;
3939
int count = 0;
40-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, testSize);
40+
IEnumerable<int> range = Enumerable.Range(0, testSize);
4141
using var tokenSource = new CancellationTokenSource();
4242
CancellationToken token = tokenSource.Token;
4343
try
@@ -70,7 +70,7 @@ public static async Task CancellationPropagationConcurrent()
7070
const int testSize = 1000000;
7171
int total = 0;
7272
int count = 0;
73-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, testSize);
73+
IEnumerable<int> range = Enumerable.Range(0, testSize);
7474
using var tokenSource = new CancellationTokenSource();
7575
CancellationToken token = tokenSource.Token;
7676
try

Open.ChannelExtensions.Tests/ExceptionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public static class ExceptionTests
44
{
55
[SuppressMessage("Roslynator", "RCS1194:Implement exception constructors.")]
6-
class TestException : Exception { }
6+
class TestException : Exception;
77

88
[Fact]
99
public static async Task ExceptionPropagation()
1010
{
1111
int count = 0;
12-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, 1000);
12+
IEnumerable<int> range = Enumerable.Range(0, 1000);
1313
try
1414
{
1515
await range
@@ -35,7 +35,7 @@ await range
3535
public static async Task TransformExceptionPropagation()
3636
{
3737
int count = 0;
38-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, 1000);
38+
IEnumerable<int> range = Enumerable.Range(0, 1000);
3939
try
4040
{
4141
await range
@@ -66,7 +66,7 @@ public static async Task ExceptionPropagationConcurrent()
6666
const int testSize = 100000000;
6767
int total = 0;
6868
int count = 0;
69-
System.Collections.Generic.IEnumerable<int> range = Enumerable.Range(0, testSize);
69+
IEnumerable<int> range = Enumerable.Range(0, testSize);
7070
await Assert.ThrowsAsync<AggregateException>(async () =>
7171
{
7272
try

Open.ChannelExtensions/BatchingChannelReader.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Diagnostics.CodeAnalysis;
5-
using System.Diagnostics.Contracts;
6-
using System.Runtime.CompilerServices;
7-
using System.Threading;
8-
using System.Threading.Channels;
9-
using System.Threading.Tasks;
10-
11-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
122

133
/// <summary>
144
/// A ChannelReader that batches results.
@@ -163,7 +153,7 @@ protected override bool TryPipeItems(bool flush)
163153
{
164154
newBatch = true; // a new batch could start but not be emmited.
165155
_batch = c = CreateBatch(_batchSize);
166-
AddBatchItem(c,item);
156+
AddBatchItem(c, item);
167157
}
168158
else
169159
{
@@ -256,7 +246,6 @@ protected override async ValueTask<bool> WaitToReadAsyncCore(
256246
}
257247

258248
/// <inheritdoc />
259-
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Expect non-null.")]
260249
public class QueueBatchingChannelReader<T> : BatchingChannelReader<T, Queue<T>>
261250
{
262251
/// <inheritdoc />
@@ -281,7 +270,6 @@ public QueueBatchingChannelReader(ChannelReader<T> source, int batchSize, bool s
281270
}
282271

283272
/// <inheritdoc />
284-
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Expect non-null.")]
285273
public class BatchingChannelReader<T> : BatchingChannelReader<T, List<T>>
286274
{
287275
/// <inheritdoc />

Open.ChannelExtensions/BufferingChannelReader.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Diagnostics.Contracts;
3-
using System.Threading;
4-
using System.Threading.Channels;
5-
using System.Threading.Tasks;
6-
7-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
82

93
/// <summary>
104
/// Base class for buffering results of a source ChannelReader.
@@ -100,7 +94,7 @@ public override bool TryRead(out TOut item)
10094
public override ValueTask<bool> WaitToReadAsync(CancellationToken cancellationToken = default)
10195
{
10296
var buffer = Buffer;
103-
if(buffer is null) return new ValueTask<bool>(false);
97+
if (buffer is null) return new ValueTask<bool>(false);
10498

10599
var completion = buffer.Reader.Completion;
106100
if (completion.IsCompleted)
@@ -142,7 +136,7 @@ protected virtual async ValueTask<bool> WaitToReadAsyncCore(ValueTask<bool> buff
142136
}
143137

144138
await s.ConfigureAwait(false);
145-
if (bufferWait.IsCompleted) return await bufferWait.ConfigureAwait(false);
139+
if (bufferWait.IsCompleted) return await bufferWait.ConfigureAwait(false);
146140
TryPipeItems(false);
147141
if (bufferWait.IsCompleted) return await bufferWait.ConfigureAwait(false);
148142

Open.ChannelExtensions/Extensions.Batch.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Threading.Channels;
4-
5-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
62

73
public static partial class Extensions
84
{

Open.ChannelExtensions/Extensions.Filter.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Diagnostics.Contracts;
3-
using System.Threading;
4-
using System.Threading.Channels;
5-
using System.Threading.Tasks;
6-
7-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
82

93
public static partial class Extensions
104
{

Open.ChannelExtensions/Extensions.Join.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Threading.Channels;
4-
using System.Threading.Tasks;
5-
6-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
72

83
public static partial class Extensions
94
{
@@ -95,7 +90,6 @@ public static ChannelReader<T> Join<T>(this ChannelReader<T[]> source, bool sing
9590
/// <param name="singleReader">True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.</param>
9691
/// <param name="allowSynchronousContinuations">True can reduce the amount of scheduling and markedly improve performance, but may produce unexpected or even undesirable behavior.</param>
9792
/// <returns>A channel reader containing the joined results.</returns>
98-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exception is propagated.")]
9993
public static ChannelReader<T> Join<T>(
10094
this ChannelReader<IAsyncEnumerable<T>> source,
10195
bool singleReader = false,

Open.ChannelExtensions/Extensions.Pipe.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
using System;
2-
using System.Diagnostics.Contracts;
3-
using System.Threading;
4-
using System.Threading.Channels;
5-
using System.Threading.Tasks;
1+
namespace Open.ChannelExtensions;
62

7-
namespace Open.ChannelExtensions;
8-
9-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Roslynator", "RCS1047:Non-asynchronous method name should not end with 'Async'.", Justification = "In order to differentiate between non async versions.")]
3+
[SuppressMessage("Roslynator", "RCS1047:Non-asynchronous method name should not end with 'Async'.", Justification = "In order to differentiate between non async versions.")]
104
public static partial class Extensions
115
{
126
/// <summary>
@@ -69,7 +63,7 @@ public static ChannelReader<T> PipeTo<T>(this ChannelReader<T> source,
6963
if (target is null) throw new ArgumentNullException(nameof(target));
7064
Contract.EndContractBlock();
7165

72-
Task.Run(()=>PipeTo(source, target.Writer, true, cancellationToken));
66+
Task.Run(() => PipeTo(source, target.Writer, true, cancellationToken));
7367

7468
return target.Reader;
7569
}

0 commit comments

Comments
 (0)