@@ -78,7 +78,7 @@ private static T[] ReadBsonArray<T>(
78
78
var span = bytes . AsSpan ( ) ;
79
79
80
80
var result = new List < T > ( ) ;
81
-
81
+
82
82
var index = 4 ; // 4 first bytes are array object size in bytes
83
83
var maxIndex = array . Length - 1 ;
84
84
@@ -103,7 +103,7 @@ private static T[] ReadBsonArray<T>(
103
103
}
104
104
case ConversionType . DoubleToDouble :
105
105
{
106
- var v = BitConverter . Int64BitsToDouble ( BinaryPrimitives . ReadInt64LittleEndian ( span . Slice ( index ) ) ) ;
106
+ var v = BinaryPrimitivesCompat . ReadDoubleLittleEndian ( span . Slice ( index ) ) ;
107
107
value = Unsafe . As < double , T > ( ref v ) ;
108
108
break ;
109
109
}
@@ -112,19 +112,22 @@ private static T[] ReadBsonArray<T>(
112
112
var lowBits = BinaryPrimitives . ReadUInt64LittleEndian ( span . Slice ( index ) ) ;
113
113
var highBits = BinaryPrimitives . ReadUInt64LittleEndian ( span . Slice ( index + 8 ) ) ;
114
114
var v = Decimal128 . ToDecimal ( Decimal128 . FromIEEEBits ( highBits , lowBits ) ) ;
115
+
115
116
value = Unsafe . As < decimal , T > ( ref v ) ;
116
117
break ;
117
118
}
118
119
case ConversionType . BoolToBool :
119
120
{
120
121
var v = span [ index ] != 0 ;
122
+
121
123
value = Unsafe . As < bool , T > ( ref v ) ;
122
124
break ;
123
125
}
124
126
case ConversionType . Int32ToInt8 :
125
127
{
126
128
var v = ( sbyte ) BinaryPrimitives . ReadInt32LittleEndian ( span . Slice ( index ) ) ;
127
129
value = Unsafe . As < sbyte , T > ( ref v ) ;
130
+
128
131
break ;
129
132
}
130
133
case ConversionType . Int32ToUInt8 :
@@ -180,10 +183,12 @@ private static T[] ReadBsonArray<T>(
180
183
}
181
184
182
185
result . Add ( value ) ;
186
+
183
187
index += bsonDataSize ;
184
188
}
185
189
186
190
ValidateBsonType ( BsonType . EndOfDocument , span ) ;
191
+
187
192
return result . ToArray ( ) ;
188
193
189
194
void ValidateBsonType ( BsonType bsonType , Span < byte > span )
0 commit comments