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

Ignore __safecontent__ field in deserialization

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.21.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      When you insert a document into an encrypted collection, the safeContent field is automatically added. (This field is necessary for QE to work.) If you attempt to then find that document and let the driver automatically deserialize it to a POCO you've defined, the driver throws an exception:

      Unhandled exception. System.FormatException: Element 'safeContent' does not match any field or property of class <your POCO class>.

      I was able to avoid this error by adding theĀ 
      [BsonIgnoreExtraElements] attribute to my POCO class, but it would be nice if the driver were aware that it should ignore that field.

      Motivation

      Who is the affected end user?

      Anyone using the C# driver for QE with POCOs

      How does this affect the end user?

      Throws an exception if the attribute is not added

      How likely is it that this problem or use case will occur?

      Assuming most users use POCOs, this is a main path error

      If the problem does occur, what are the consequences and how severe are they?

      The app doesn't work without the attribute

      Is this ticket required by a downstream team?

      No

      Is this ticket only for tests?

      No

      Acceptance Criteria

      Ideally, I wouldn't need to add this attribute to the class in order for QE to work with POCOs. If that's not possible, we can discuss documenting this requirement somewhere.

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            mike.woofter@mongodb.com Mike Woofter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: