Details
-
Bug
-
Resolution: Done
-
Major - P3
-
2.0.1
-
None
Description
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);
|