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

BsonSerializer RegisterSerializer should validate serializer argument

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.4.3
    • Component/s: Serialization
    • Labels:
    • Fully Compatible

      The untyped overloads of RegisterSerializer can't catch type mismatches at compile time. They are currently not being caught at runtime either, and mismatches result in difficult to diagnose errors later on when the driver attempts to use the mismatched serializer.

      For example, the following should be a runtime error:

      var xserializer = new XSerializer();
      BsonSerializer.RegisterSerializer(typeof(Y), xserializer);
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: