@@ -9,55 +9,55 @@ internal static class StreamHelpers
9
9
{
10
10
public static short ReadInt16 ( this Stream stream )
11
11
{
12
- Span < byte > data = stackalloc byte [ 2 ] ;
12
+ Span < byte > data = stackalloc byte [ sizeof ( Int16 ) ] ;
13
13
14
14
stream . Read ( data ) ;
15
15
return BitConverter . ToInt16 ( data ) ;
16
16
}
17
17
18
18
public static ushort ReadUInt16 ( this Stream stream )
19
19
{
20
- Span < byte > data = stackalloc byte [ 2 ] ;
20
+ Span < byte > data = stackalloc byte [ sizeof ( UInt16 ) ] ;
21
21
22
22
stream . Read ( data ) ;
23
23
return BitConverter . ToUInt16 ( data ) ;
24
24
}
25
25
26
26
public static int ReadInt32 ( this Stream stream )
27
27
{
28
- Span < byte > data = stackalloc byte [ 4 ] ;
28
+ Span < byte > data = stackalloc byte [ sizeof ( Int32 ) ] ;
29
29
30
30
stream . Read ( data ) ;
31
31
return BitConverter . ToInt32 ( data ) ;
32
32
}
33
33
34
34
public static long ReadInt64 ( this Stream stream )
35
35
{
36
- Span < byte > data = stackalloc byte [ 8 ] ;
36
+ Span < byte > data = stackalloc byte [ sizeof ( Int64 ) ] ;
37
37
38
38
stream . Read ( data ) ;
39
39
return BitConverter . ToInt64 ( data ) ;
40
40
}
41
41
42
42
public static uint ReadUInt32 ( this Stream stream )
43
43
{
44
- Span < byte > data = stackalloc byte [ 4 ] ;
44
+ Span < byte > data = stackalloc byte [ sizeof ( UInt32 ) ] ;
45
45
46
46
stream . Read ( data ) ;
47
47
return BitConverter . ToUInt32 ( data ) ;
48
48
}
49
49
50
50
public static ulong ReadUInt64 ( this Stream stream )
51
51
{
52
- Span < byte > data = stackalloc byte [ 8 ] ;
52
+ Span < byte > data = stackalloc byte [ sizeof ( UInt64 ) ] ;
53
53
54
54
stream . Read ( data ) ;
55
55
return BitConverter . ToUInt64 ( data ) ;
56
56
}
57
57
58
58
public static float ReadFloat ( this Stream stream )
59
59
{
60
- Span < byte > data = stackalloc byte [ 4 ] ;
60
+ Span < byte > data = stackalloc byte [ sizeof ( float ) ] ;
61
61
62
62
stream . Read ( data ) ;
63
63
return BitConverter . ToSingle ( data ) ;
0 commit comments