-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Use ValueTask-returning async FileStream methods wherever possible #51050
Comments
Tagging subscribers to this area: @carlossanlop Issue DetailsWith #50802 and the next upcoming PR from @carlossanlop the following ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default)
ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) The "old", Task-returning overloads are still going to be allocating memory: Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) The person who is willing to work on this task should:
Note: some of the libraries are still targeting .NET Standard or even Full .NET Framework. For these libs, you might need to use conditional compilation like in the example below: runtime/src/libraries/System.IO.FileSystem/src/System/IO/File.cs Lines 986 to 990 in 0af5228
|
This is unlikely to be very fruitful. I've previously made passes through to fix all such stream usage, and we now have an analyzer that flags such usage. runtime/eng/CodeAnalysis.ruleset Line 115 in 0af5228
|
@stephentoub I agree, I just want someone to set it to
Thanks! We are going to mention the analyser in our FileStream perf best practices docs 👍 |
What does this mean? Do you mean the analyzer? We treat warnings as errors. |
I was not aware of that. In such a case, I am just going to close the issue. Thanks! |
With #50802 and the next upcoming PR from @carlossanlop the following
FileStream
methods are going to become allocation-free:The "old", Task-returning overloads are still going to be allocating memory:
The person who is willing to work on this task should:
Note: some of the libraries are still targeting .NET Standard or even Full .NET Framework. For these libs, you might need to use conditional compilation like in the example below:
runtime/src/libraries/System.IO.FileSystem/src/System/IO/File.cs
Lines 986 to 990 in 0af5228
The text was updated successfully, but these errors were encountered: