Skip to content

Commit 8e15dcf

Browse files
committed
fix: Fixes Nullable struct type reading
Fixes: #271
1 parent 88bdf8b commit 8e15dcf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

MLAPI/Serialization/BitReader.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,14 @@ public object ReadObjectPacked(Type type)
208208
((IBitWritable)instance).Read(this.source);
209209
return instance;
210210
}
211-
211+
212+
Type nullableUnderlyingType = Nullable.GetUnderlyingType(type);
213+
214+
if (nullableUnderlyingType != null && SerializationManager.IsTypeSupported(nullableUnderlyingType))
215+
{
216+
return ReadObjectPacked(nullableUnderlyingType);
217+
}
218+
212219
throw new ArgumentException("BitReader cannot read type " + type.Name);
213220
}
214221

0 commit comments

Comments
 (0)