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

ISupportInitialize methods not called when class derives from Dictionary

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Gone away
    • Icon: Unknown Unknown
    • None
    • None
    • None
    • None

    Description

      Summary

      ISupportInitialize methods are not called when document class derives from Dictionary<string, object>.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      MongoDB.Driver 2.17.1

      How to Reproduce

      Consider following document class:

      public class MyType: Dictionary<string, object>, ISupportInitialize
      {{{}}
          [BsonId]
          public string Id
          {
              get => (string)this["id"];
              set => this["id"] = value;
      {{    }}}

          public void BeginInit()
          {
              // this never gets executed:
              throw new NotImplementedException();
      {{    }}}

          public void EndInit()
          {
              // this never gets executed:
              throw new NotImplementedException();
      {{    }}}
      }

       

      Now enumerating the collection deserializes the items correctly as Dictionary objects, but BeginInit() and EndInit() never get called.

       

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

      Attachments

        Activity

          People

            james.kovacs@mongodb.com James Kovacs
            mywyb2@gmail.com Mo B.
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: