Stream.Read assumed to fill the buffer (CA2022)
Ce contenu n’est pas encore disponible dans votre langue.
Key dotnet.resource.inexact-stream-read · Severity warning · Category resource
Microsoft analyzer CA2022. Flags Stream.Read/ReadAsync whose return value is ignored. Read may return fewer bytes than asked for; the rest of the buffer is then stale data.
Incorrect
Section titled “Incorrect”var buffer = new byte[length];await stream.ReadAsync(buffer, ct);Correct
Section titled “Correct”var buffer = new byte[length];await stream.ReadExactlyAsync(buffer, ct);