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

Better error message when document being deserialized doesn't match class declaration

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.3.1
    • Affects Version/s: 1.3
    • Component/s: None
    • None
    • Minor Change

      Given the following classes:

      public class C

      { public int _id; public N n; }

      public class N

      { public int x; }

      the following code results in an InvalidOperationException:

      var json = "

      { '_id' : 1, n : 'should be a document, not a string' }

      ";
      BsonSerializer.Deserialize<C>(json);

      The error message should be more specific, identifying which property of which class couldn't be deserialized.

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

              Created:
              Updated:
              Resolved: