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

BsonSerializer RegisterSerializer should validate serializer argument

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.4.3
    • Serialization
    • Fully Compatible

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: