C#


ROSLYN.PERFORMANCE.CA1835 : Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' (C#)

See Roslyn-Detected C# Warning Classes for more information.

Summary

'Stream' has a 'ReadAsync' overload that takes a 'Memory' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory' as the first argument. Prefer calling the memory based overloads, which are more efficient.

This check corresponds to Roslyn rule CA1835. For full rule details, see the Microsoft website: CA1835.

Properties

Class Name Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' (C#)
Significance reliability
Mnemonic ROSLYN.PERFORMANCE.CA1835
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' (C#)"

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.