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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker - P1
    • Resolution: Duplicate
    • 1.3.1
    • None
    • None
    • Fully Compatible

    Description

      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)

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: