-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: 2.18.0
-
Component/s: Configuration
-
None
BsonClassMap __classMaps is static mutable, with popsicle immutablity.
This makes:
- Testing class maps in isolation is impossible.
- Prevents parallel testing because setup is not thread-safe and (negative productivity effect)
- Doesn't allow runtime service resolution of things like jsonserializers.
- Problematic when using two or more seperate mongo databases in same process space (they end up sharing ClassMaps).
Instead, perhaps, add a BsonClassMaps custom collection, move the static methods to there as non-static and allow it to be injected into a MongoClient (vis MongoClientSettings).
services.AddBsonClassMaps(map => map.RegisterClassMap<>...);