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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 1.3.1
    • 1.3
    • None
    • None
    • Minor Change

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: