File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ public bool TryReadCollectionHeader(out int length)
297
297
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
298
298
public bool PeekIsNull ( )
299
299
{
300
- return TryPeekObjectHeader ( out _ ) ;
300
+ var code = GetSpanReference ( 1 ) ;
301
+ return code == MemoryPackCode . NullObject ;
301
302
}
302
303
303
304
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
Original file line number Diff line number Diff line change @@ -306,7 +306,8 @@ public bool TryReadCollectionHeader(out int length)
306
306
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
307
307
public bool PeekIsNull ( )
308
308
{
309
- return TryPeekObjectHeader ( out _ ) ;
309
+ var code = GetSpanReference ( 1 ) ;
310
+ return code == MemoryPackCode . NullObject ;
310
311
}
311
312
312
313
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
Original file line number Diff line number Diff line change @@ -167,4 +167,15 @@ public void ValidateInvalidLengthTest()
167
167
catch ( MemoryPackSerializationException ) { }
168
168
}
169
169
170
+ [ Fact ]
171
+ public void PeekIsNull ( )
172
+ {
173
+ var bin = MemoryPackSerializer . Serialize < string > ( null ) ;
174
+
175
+ using var state = MemoryPackReaderOptionalStatePool . Rent ( null ) ;
176
+ var reader = new MemoryPackReader ( bin , state ) ;
177
+
178
+ var isNull = reader . PeekIsNull ( ) ;
179
+ isNull . Should ( ) . BeTrue ( ) ;
180
+ }
170
181
}
You can’t perform that action at this time.
0 commit comments