Skip to content

Commit 44359df

Browse files
committed
Fix CA2022 warning: Avoid inexact read with 'System.IO.Stream.Read(byte[], int, int)'
1 parent bf428d1 commit 44359df

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Source/HttpMultipartParser.UnitTests/ParserScenarios/FileChunkStartsWithBOM.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@ public void CanHandleBOM()
6363

6464
// Read the padding and assert we get the expected value
6565
var paddingBuffer = new byte[_padding.Length];
66-
file.Read(paddingBuffer, 0, paddingBuffer.Length);
66+
var readCount = file.Read(paddingBuffer, 0, paddingBuffer.Length);
6767

6868
Assert.Equal(_padding, Encoding.UTF8.GetString(paddingBuffer));
6969

7070
// Read the BOM and assert we get the expected value
7171
var bomBuffer = new byte[_utf8BOMBinary.Length];
72-
file.Read(bomBuffer, 0, bomBuffer.Length);
72+
readCount = file.Read(bomBuffer, 0, bomBuffer.Length);
7373

7474
// If this assertion fails, it means that we have reproduced the problem described in GH-64
7575
// If it succeeds, it means that the bug has been fixed.
7676
Assert.Equal(_utf8BOMString, Encoding.UTF8.GetString(bomBuffer));
7777

7878
// Read the rest of the content and assert we get the expected value
7979
var restOfContentBuffer = new byte[_fileContent.Length - _padding.Length - _utf8BOMString.Length];
80-
file.Read(restOfContentBuffer, 0, restOfContentBuffer.Length);
80+
readCount = file.Read(restOfContentBuffer, 0, restOfContentBuffer.Length);
8181

8282
Assert.Equal("Hello world", Encoding.UTF8.GetString(restOfContentBuffer));
8383
}

0 commit comments

Comments
 (0)