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

Array serialization options for items are not always being used at deserialization time

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5
    • Affects Version/s: 1.4.2
    • Component/s: None
    • None

      To reproduce use this class:

      public class C
      {
          public ObjectId Id;
          [BsonRepresentation(BsonType.ObjectId)] // applies to items not to array
          public string[] X;
      }
      

      and this code:

      var c = new C { X = new string[] { ObjectId.GenerateNewId().ToString(), ObjectId.GenerateNewId().ToString() } };
      var json = c.ToJson();
      Console.WriteLine(json);
      
      var d = BsonSerializer.Deserialize<C>(json); // throws exception because of this bug
      Console.WriteLine(d.ToJson());
      

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

              Created:
              Updated:
              Resolved: