Details
-
Bug
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
1.10.1
-
None
Description
Consider the following simple immutable class that uses the [BsonConstructor] attribute to configure class map based serialization:
public class C
|
{
|
private readonly int _x;
|
|
|
[BsonConstructor]
|
public C(int x)
|
{
|
_x = x;
|
}
|
|
|
[BsonElement]
|
public int X
|
{
|
get { return _x; }
|
}
|
}
|
The constructor argument "x" is matched with the property "X" (using case insensitive matching).
Now consider the following variation of the constructor which compiles correctly but doesn't work for deserialization:
[BsonConstructor]
|
public C(int y)
|
{
|
_x = y;
|
}
|
In this case, the constructor argument "y" can't be matched with any property, so this is an error.
Currently the driver is throwing a NullReferenceException when a constructor parameter can't be matched with a property. It should throw a more informative exception.