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

Exception when applying BsonRepresentation to ReadOnlyCollection

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • 2.9.1
    • Serialization
    • None

    Description

      If I try do the following:

      [BsonRepresentation(BsonType.ObjectId)]
      public ReadOnlyCollection<string> References { get; private set; }
      

      I get an exception when registering the class:

       

      System.NotSupportedException: A serializer of type 'ReadOnlyCollectionSerializer<String>' is not configurable using an attribute of type 'BsonRepresentationAttribute'

       

      I suspect this is because the ReadOnlyCollectionSerializer does not implement the IChildSerializerConfigurable interface, unlike most other collection serializers. Is there a reason for this?

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            tgraham@systemssoftware.com.au Taylor Graham
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: