-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.1
-
Component/s: Serialization
-
None
Given the following immutable class:
public class C { [BsonElement] public int X { get; } [BsonExtraElements] [BsonDefaultValue(null)] public BsonDocument E { get; } [BsonConstructor] public C(int x, BsonDocument e) { X = x; E = e; } }
Attempting to deserialize a document with an extra element throws a NullReferenceException.
To reproduce:
var json = "{ X : 1, Y : 2 }"; var c = BsonSerializer.Deserialize<C>(json);