Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4487

Make BsonClassMap entirely non-static

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 2.18.0
    • Component/s: Configuration
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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<>...);

            Assignee:
            Unassigned Unassigned
            Reporter:
            dhickey@gmail.com Damian Hickey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: