Details
-
Bug
-
Resolution: Done
-
Unknown
-
2.17.0
-
None
-
None
Description
Summary
BsonClassMapSerializer throws a NullReferenceException when BsonClassMap::CreateInstance() returns null, which may happen if one has configured a creator on the map and that creator fails silently returning nulls instead of object instances (think of DI containers)
How to Reproduce
Simulate a failing creator:
BsonClassMap .LookupClassMap(typeof(MyModel)) .SetCreator(() => {
|
//could be something like:
|
//ServiceProvider.GetService(domainObjType) |
|
|
//that may... |
return null; |
});
|
Execute a Find() on that type:
var filter = SetupTheFilterDefinition();
|
var results = collection.Find<MyModel>(filter).ToList();
|