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

c# driver to auto register all explicitly mapped types as allowed

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Serialization
    • 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?

      I originally posted this here before realizing it should probably have gone in Jira as a feature request?

       
      With release 2.19.0 we now have to register our types in order for them to be serialized. The suggestion in the release notes here is to do the following…

      var objectSerializer = new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.FullName.StartsWith("MyNamespace"));
      BsonSerializer.RegisterSerializer(objectSerializer);
      

      This works, however, at the company I work we explicitly register all our types using BsonClassMap.RegisterClassMap<T>(...) to avoid accidents when serializing/deserializing.

      Given that we’re already being explicit about the types we want registered could the library note these types and add them to the allowed types automatically.

            Assignee:
            Unassigned Unassigned
            Reporter:
            g.budden@quill.co.uk Gareth Budden
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: