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

Support overriden properties with covariant return type

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      C# 9 introduced return type covariance, and that allows us to override properties with more specific types. MongoDB's driver can't serialize such properties at the moment.

      Example:

      {}

      public class Entity
      {
          public virtual object SomeProperty { get; set; }
      }
      

      {{And:}}
      {}

      public class User : Entity
      {
          public override string SomeProperty { get; set; }
      }
      

      {{The Mongo BSON serializer thinks these are two separate properties, and it throws an exception because there are two properties that map to the same element.}}

       

      (BTW, I'm new here so if I did something wrong with this feature request please let me know){}

       

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            gur@kissterra.com Gur Galler
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: