-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes unnecessary CA2022 suppression pragmas and updates the code to directly discard the result of Stream.ReadAsync to trigger a pipe state update.
- Removed CA2022 suppressions from both ConnectionHost.cs and Client.cs.
- Updated asynchronous read calls to assign the result to a discard.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/RazorSdk/Tool/ConnectionHost.cs | Removed warning suppressions and updated the read operation. |
src/RazorSdk/Tool/Client.cs | Removed warning suppressions and updated the read operation. |
Thanks for your PR, @@Winniexu01. |
#pragma warning disable CA2022 // Avoid inexact read | ||
await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken); | ||
#pragma warning restore CA2022 | ||
_ = await Stream.ReadAsync(Array.Empty<byte>(), 0, 0, cancellationToken); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: 3137672
Fixes dotnet/source-build#4322
Stream.ReadAsync
method.In the code, we need to trigger a state update on a
Pipestream
without actualy reading data. UsingStream.ReadExactlyAsync
with a zero-length buffer will not update the state of the pipe: Remove unnecessary CA2022 suppressions #47904 (comment)