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

Analyzer: Prefer Memory overloads for Stream async Read/Write methods #3497

Merged

Conversation

carlossanlop
Copy link
Member

@carlossanlop carlossanlop commented Apr 14, 2020

Contributes to dotnet/runtime#33790

Summary

If the user invokes any of these methods from an object that is or inherits from Stream:

ReadAsync(Byte[], Int32, Int32)
ReadAsync(Byte[], Int32, Int32, CancellationToken)
WriteAsync(Byte[], Int32, Int32)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

We should suggest to instead use:
ReadAsync(Memory<Byte>, CancellationToken)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

All unit tests passed locally.

@carlossanlop carlossanlop force-pushed the PreferStreamAsyncMemoryOverloads branch from 92b2053 to 3369442 Compare April 27, 2020 21:29
Copy link
Contributor

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@carlossanlop
Copy link
Member Author

@buyaa-n @stephentoub @bartonjs can I get a sign off from you please, if everything looks good?

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Small comment, looks good, thanks!

Co-Authored-By: buyaa-n <buyankhishig.namnan@microsoft.com>
@carlossanlop carlossanlop merged commit b09efe5 into dotnet:master Apr 29, 2020
@carlossanlop carlossanlop deleted the PreferStreamAsyncMemoryOverloads branch April 29, 2020 00:01
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