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

Override Stream ReadAsync/WriteAsync Analyzer #4725

Conversation

NewellClark
Copy link
Contributor

This fixes issue #33789.

I ran the analyzer against dotnet/runtime and found several violations:

  • DeflateStream, ChunkedMemoryStream, RequestStream, and NetworkStreamWrapper were all trivial, and have been dealt with in this PR.
  • CryptoStream was non-trivial, and is being worked on in this PR.
  • DeflateManagedStream is internal, and calls into the IFileFormatReader interface, which is also internal. I was unable to find any classes that actually implement this interface throughout dotnet/runtime.
    We could do what we're doing for CryptoStream and check if the Memory<byte> is actually an array, and if not simply do the copy, but since this interface is internal, I figured we might be able to explore other options.
  • WebSocketHttpListenerDuplexStream is also internal, and from what I could find, ReadAsync/WriteAsync are only ever called from WebSocketBase, which only calls the array-based override. Unfortunately, WebSocketHttpListenerDuplexStream also calls back into WebSocket, and it passes the array it was given into multiple different methods on WebSocket, and some methods on WebSocketBuffer. Providing memory-based overrides would require almost a complete rewrite of WebSocketBuffer as well as changes to code that consumes it. Since nothing currently calls the memory-based overrides on WebSocketHttpListenerDuplexStream, I think we should strongly consider suppressing the warning.

sharwell and others added 30 commits April 22, 2020 12:34
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
Remove rule CA1801 - replaced by IDE0060
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
Mateo Torres Ruiz and others added 24 commits January 8, 2021 14:29
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
….0.1xx-preview1

Merge master to release/6.0.1xx-preview1
* Ensure CA1835 preserves nullability

* Remove spacing from VB file.

* Add extra nullability sub-cases in new unit tests.

* Remove extra space causing CI failure.

* Add nullability tests with CancellationToken

Co-authored-by: carlossanlop <[email protected]>
Revert workaround for old SyntaxGenerator bug
Make all rules warning for RulesetKind.AllEnabled
@NewellClark NewellClark requested a review from a team as a code owner January 21, 2021 18:42
@mavasani
Copy link
Contributor

@NewellClark Seems like your PR has many more changes then intended.

@mavasani
Copy link
Contributor

The target branch seems to be incorrect dotnet:merges/master-to-release/6.0.1xx-preview1. Did you intend to target master or release/6.0.1xx-preview1?

@NewellClark
Copy link
Contributor Author

NewellClark commented Jan 21, 2021

Did you intend to target master or release/6.0.1xx-preview1?

Oops, so I did. I will fix it.

@NewellClark NewellClark deleted the issue-33789 branch January 21, 2021 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants