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

Use IBsonSerializationOptions in Deserialize/Serialize methods in the various Bson/Serialization/Serializers/*

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Blocker - P1 Blocker - P1
    • None
    • Affects Version/s: 1.3.1
    • Component/s: None
    • Fully Compatible

      Possibly related to CSHARP-284 and CSHARP-308?

      I noticed in the various serializers in Bson/Serialization/Serializers/ that the Deserialize and Serialize methods were ignoring the given IBsonSerializationOptions. Is this by design?

      I recently came across an issue by attempting to use the BsonRepresentationAttribute on a collection, e.g.:

      [BsonRepresentation(BsonType.Int64, AllowOverflow = true)]
      public List<UInt64> Ids

      { get; set; }

      Then I hit an OverflowException when calling ToJson on my object:

      System.OverflowException: Arithmetic operation resulted in an overflow.
      at MongoDB.Bson.Serialization.Options.RepresentationSerializationOptions.ToInt64(UInt64 value)
      at MongoDB.Bson.Serialization.Serializers.UInt64Serializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)
      at MongoDB.Bson.Serialization.BsonClassMapSerializer.SerializeMember(BsonWriter bsonWriter, Object obj, BsonMemberMap memberMap)
      at MongoDB.Bson.Serialization.BsonClassMapSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)
      at MongoDB.Bson.Serialization.BsonSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options)
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, IBsonSerializationOptions options, JsonWriterSettings settings)
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, JsonWriterSettings settings)
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType)
      at MongoDB.Bson.BsonExtensionMethods.ToJson[TNominalType](TNominalType obj)

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            dmarien Doug Marien
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: