Skip to content
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

Suppress CA2022 warnings in VB code #9570

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Oct 28, 2024

These warnings are helpful in general. They flag apparently incorrect use of Stream.Read, where the return value is unused. In the abstract, reading from a stream into a buffer is not guaranteed to return all the bytes requested, as those bytes may not yet be available.

The cases covered by these three diagnostics are all in very old VB code, which hasn't been touched in ~15 years. My investigation suggests that all usages operate on MemoryStream which will actually always return the bytes you request.

I feel it's less risky to just suppress these warnings rather than trying to fix them.

With these suppressions we are back to having no warnings during rebuild.

dotnet/roslyn-analyzers#7208

Microsoft Reviewers: Open in CodeFlow

@drewnoakes drewnoakes added the Feature-Resource-Designer The legacy resource file (RESX) editor. label Oct 28, 2024
@drewnoakes drewnoakes requested a review from a team as a code owner October 28, 2024 08:50
@dkurepa
Copy link
Member

dkurepa commented Oct 28, 2024

/azp run

@dkurepa dkurepa closed this Oct 28, 2024
@dkurepa dkurepa reopened this Oct 28, 2024
@dkurepa dkurepa closed this Oct 28, 2024
@dkurepa dkurepa reopened this Oct 28, 2024
@drewnoakes
Copy link
Member Author

/azp run

@drewnoakes drewnoakes closed this Oct 29, 2024
@drewnoakes drewnoakes reopened this Oct 29, 2024
@drewnoakes
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

These warnings are helpful in general. They flag apparently incorrect use of `Stream.Read`, where the return value is unused. In the abstract, reading from a stream into a buffer is not guaranteed to return all the bytes requested, as those bytes may not yet be available.

The cases covered by these three diagnostics are all in very old VB code, which hasn't been touched in ~15 years. My investigation suggests that all usages operate on `MemoryStream` which will actually always return the bytes you request.

I feel it's less risky to just suppress these warnings rather than trying to fix them.
@drewnoakes drewnoakes merged commit 4aab68c into dotnet:main Oct 29, 2024
5 checks passed
@drewnoakes drewnoakes deleted the suppress-warnings branch October 29, 2024 11:18
@dotnet-policy-service dotnet-policy-service bot added this to the 17.12 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Resource-Designer The legacy resource file (RESX) editor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants