Skip to content

Conversation

@Winniexu01
Copy link
Member

Fixes dotnet/source-build#4322

  • Remove all the unnecessary CA2022 suppressions.
  • Keep Stream.ReadAsync method.
    In the code, we need to trigger a state update on a Pipestream without actualy reading data. Using Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe: Remove unnecessary CA2022 suppressions #47904 (comment)

Copilot AI review requested due to automatic review settings April 29, 2025 08:32
@Winniexu01 Winniexu01 requested a review from a team as a code owner April 29, 2025 08:32
Copy link
Contributor

Copilot AI left a 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.

@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Apr 29, 2025
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@Winniexu01.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

#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);
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

@MichaelSimons MichaelSimons merged commit a49a135 into dotnet:main Apr 30, 2025
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unnecessary CA2022 suppressions

3 participants