File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
test/Microsoft.NET.TestFramework/Utilities Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ namespace Microsoft . NET . TestFramework . Utilities
5
+ {
6
+ internal static class BitConverterExtensions
7
+ {
8
+ extension ( BitConverter )
9
+ {
10
+ public static uint ToUInt32 ( ReadOnlySpan < byte > value )
11
+ {
12
+ var buffer = new byte [ 4 ] ;
13
+ value . CopyTo ( buffer ) ;
14
+ return BitConverter . ToUInt32 ( buffer , 0 ) ;
15
+ }
16
+ }
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ namespace Microsoft . NET . TestFramework . Utilities
5
+ {
6
+ internal static class StreamExtensions
7
+ {
8
+ extension ( Stream stream )
9
+ {
10
+ public void ReadExactly ( Span < byte > buffer )
11
+ {
12
+ int bytesRead = 0 ;
13
+ byte [ ] arrayBuffer = new byte [ buffer . Length ] ;
14
+ while ( bytesRead < buffer . Length )
15
+ {
16
+ int read = stream . Read ( arrayBuffer , bytesRead , buffer . Length - bytesRead ) ;
17
+ if ( read == 0 )
18
+ {
19
+ throw new EndOfStreamException ( "Unexpected end of stream while reading Mach-O file." ) ;
20
+ }
21
+ bytesRead += read ;
22
+ }
23
+ arrayBuffer . CopyTo ( buffer ) ;
24
+ }
25
+ }
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments