Skip to content

Commit 9d1aec2

Browse files
Improve task scheduling and code quality
- Simplified `SuppressMessage` attributes in `BasicTests.cs` and `BufferingChannelReader.cs` for cleaner metadata. - Updated `Task.ContinueWith` in `Extensions._.cs` to use `TaskContinuationOptions.ExecuteSynchronously` and `TaskScheduler.Current` for better performance. - Incremented project version to 9.1.1 in `Open.ChannelExtensions.csproj`. - Introduced conditional compilation for `SyncLock` in `BufferingChannelReader.cs` to support .NET 9.0+ features. - Removed unnecessary global `SuppressMessage` in `_Global.cs` after addressing the underlying issue.
1 parent c760771 commit 9d1aec2

File tree

5 files changed

+4
-6
lines changed

5 files changed

+4
-6
lines changed

Open.ChannelExtensions.Tests/BasicTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class BasicTests
99
[InlineData(testSize1)]
1010
[InlineData(testSize2)]
1111
[SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly", Justification = "Testing only.")]
12-
[SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "<Pending>")]
12+
[SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression")]
1313
public static async Task DeferredWriteRead(int testSize)
1414
{
1515
IEnumerable<int> range = Enumerable.Range(0, testSize);

Open.ChannelExtensions/Extensions._.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static ChannelReader<TSource> PropagateCompletion<TSource, TTarget>(
109109
target.TryComplete(t.Exception);
110110
else
111111
target.TryComplete();
112-
}, cancellationToken);
112+
}, cancellationToken, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Current);
113113

114114
return source;
115115
}

Open.ChannelExtensions/Open.ChannelExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<RepositoryType>git</RepositoryType>
2323
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2424
<GenerateDocumentationFile>true</GenerateDocumentationFile>
25-
<Version>9.1.0</Version>
25+
<Version>9.1.1</Version>
2626
<PackageReleaseNotes>Ensure the current task scheduler is used and that it can be configured.</PackageReleaseNotes>
2727
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2828
<PublishRepositoryUrl>true</PublishRepositoryUrl>

Open.ChannelExtensions/Readers/BufferingChannelReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class BufferingChannelReader<TIn, TOut> : ChannelReader<TOut>
2020
/// <summary>
2121
/// The synchronization lock for the buffer.
2222
/// </summary>
23-
[SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
23+
[SuppressMessage("Design", "CA1051:Do not declare visible instance fields")]
2424
#if NET9_0_OR_GREATER
2525
protected readonly System.Threading.Lock SyncLock = new();
2626
#else

Open.ChannelExtensions/_Global.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@
88
global using System.Threading;
99
global using System.Threading.Channels;
1010
global using System.Threading.Tasks;
11-
12-
[assembly: SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "<Pending>", Scope = "member", Target = "~M:Open.ChannelExtensions.Extensions.PropagateCompletion``2(System.Threading.Channels.ChannelReader{``0},System.Threading.Channels.ChannelWriter{``1},System.Threading.CancellationToken)~System.Threading.Channels.ChannelReader{``0}")]

0 commit comments

Comments
 (0)