File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed
test/dotnet.Tests/CommandTests/Solution Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -583,9 +583,22 @@ public void WhenProjectIsAddedSolutionHasUTF8BOM(string solutionCommand)
583
583
using ( var stream = new FileStream ( Path . Combine ( projectDirectory , "App.sln" ) , FileMode . Open ) )
584
584
{
585
585
var bytes = new byte [ preamble . Length ] ;
586
- #pragma warning disable CA2022 // Avoid inexact read
587
- stream . Read ( bytes , 0 , bytes . Length ) ;
588
- #pragma warning restore CA2022 // Avoid inexact read
586
+ #if NET
587
+ stream . ReadExactly ( bytes , 0 , bytes . Length ) ;
588
+ #else
589
+ int offset = 0 ;
590
+ int count = bytes . Length ;
591
+ while ( count > 0 )
592
+ {
593
+ int read = stream . Read ( bytes , offset , count ) ;
594
+ if ( read <= 0 )
595
+ {
596
+ throw new EndOfStreamException ( ) ;
597
+ }
598
+ offset += read ;
599
+ count -= read ;
600
+ }
601
+ #endif
589
602
bytes . Should ( ) . BeEquivalentTo ( preamble ) ;
590
603
}
591
604
}
Original file line number Diff line number Diff line change @@ -544,9 +544,22 @@ public void WhenProjectIsRemovedSolutionHasUTF8BOM(string solutionCommand)
544
544
using ( var stream = new FileStream ( Path . Combine ( projectDirectory , "App.sln" ) , FileMode . Open ) )
545
545
{
546
546
var bytes = new byte [ preamble . Length ] ;
547
- #pragma warning disable CA2022 // Avoid inexact read
548
- stream . Read ( bytes , 0 , bytes . Length ) ;
549
- #pragma warning restore CA2022 // Avoid inexact read
547
+ #if NET
548
+ stream . ReadExactly ( bytes , 0 , bytes . Length ) ;
549
+ #else
550
+ int offset = 0 ;
551
+ int count = bytes . Length ;
552
+ while ( count > 0 )
553
+ {
554
+ int read = stream . Read ( bytes , offset , count ) ;
555
+ if ( read <= 0 )
556
+ {
557
+ throw new EndOfStreamException ( ) ;
558
+ }
559
+ offset += read ;
560
+ count -= read ;
561
+ }
562
+ #endif
550
563
bytes . Should ( ) . BeEquivalentTo ( preamble ) ;
551
564
}
552
565
}
You can’t perform that action at this time.
0 commit comments