diff --git a/eng/Common.globalconfig b/eng/Common.globalconfig index fd878420d57..3590395a013 100644 --- a/eng/Common.globalconfig +++ b/eng/Common.globalconfig @@ -310,7 +310,7 @@ dotnet_diagnostic.CA1833.severity = warning dotnet_diagnostic.CA1834.severity = suggestion # Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' -dotnet_diagnostic.CA1835.severity = suggestion +dotnet_diagnostic.CA1835.severity = warning # Prefer IsEmpty over Count dotnet_diagnostic.CA1836.severity = suggestion diff --git a/src/Shared/CommunicationsUtilities.cs b/src/Shared/CommunicationsUtilities.cs index 2651cc3b0ae..670ba076324 100644 --- a/src/Shared/CommunicationsUtilities.cs +++ b/src/Shared/CommunicationsUtilities.cs @@ -465,7 +465,7 @@ internal static async Task ReadAsync(Stream stream, byte[] buffer, int byte int totalBytesRead = 0; while (totalBytesRead < bytesToRead) { - int bytesRead = await stream.ReadAsync(buffer, totalBytesRead, bytesToRead - totalBytesRead); + int bytesRead = await stream.ReadAsync(buffer.AsMemory(totalBytesRead, bytesToRead - totalBytesRead), CancellationToken.None); if (bytesRead == 0) { return totalBytesRead;