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

Deserializing a public property with a private setter

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 0.5
    • None
    • None
    • All

    Description

      A public property with a private setter will throw. E.g::

      public IList<EventSession> Sessions

      { get; private set; }

      Error is occurring inBsonPropertyMapper.cs line 226 because call to propertyInfo.GetSetmethod() is throwing.

      public override Action<object, object> Setter {
      get {
      if (setter == null)

      { var setMethodInfo = propertyInfo.GetSetMethod(); // This throws var setMethodDelegate = (Action<TClass, TProperty>) Delegate.CreateDelegate(typeof(Action<TClass, TProperty>), setMethodInfo); setter = (obj, value) => setMethodDelegate((TClass) obj, (TProperty) value); }

      return setter;
      }
      }

      Attachments

        Activity

          People

            craig.wilson@mongodb.com Craig Wilson
            zippy1981 Justin Dearing
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: