Skip to content

Remove unnecessary CA2022 suppressions #48766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/RazorSdk/Tool/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation
try
{
ServerLogger.Log($"Before poking pipe {Identifier}.");
#pragma warning disable CA2022 // Avoid inexact read
await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
#pragma warning restore CA2022
// Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe.
// We need to trigger a state update without actually reading the data.
_ = await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider leaving comments explaining why we can't use ReadExactAsync so someone doesn't try to "fix" that in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: 3137672

ServerLogger.Log($"After poking pipe {Identifier}.");
}
catch (OperationCanceledException)
Expand Down
6 changes: 3 additions & 3 deletions src/RazorSdk/Tool/ConnectionHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation
try
{
ServerLogger.Log($"Before poking pipe {Identifier}.");
#pragma warning disable CA2022 // Avoid inexact read
await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
#pragma warning restore CA2022
// Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe.
// We need to trigger a state update without actually reading the data.
_ = await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken);
ServerLogger.Log($"After poking pipe {Identifier}.");
}
catch (OperationCanceledException)
Expand Down