SerializerFinder resolve wrong serializer for BsonDocument members

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 3.8.0
    • Affects Version/s: 3.7.0, 3.7.1
    • Component/s: None
    • None
    • None
    • Fully Compatible
    • Dotnet Drivers
    • Not Needed
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      Simple repro:

      var filter = Builders<ClassWithBsonTypes>.Filter.Eq(o => o.BsonDocument.ElementCount, 1);
      filter.Render(new(BsonSerializer.SerializerRegistry.GetSerializer<ClassWithBsonTypes>(), BsonSerializer.SerializerRegistry));
      
      public class ClassWithBsonTypes
      {
          public BsonDocument BsonDocument { get; set; }
      }
      

      fails with:
      System.ArgumentException: Serializer value type MongoDB.Bson.BsonValue is incompatible with expression value type System.Int32 (Parameter 'serializer')

            Assignee:
            Oleksandr Poliakov
            Reporter:
            Boris Dogadov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: