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

Init properties sometimes are not serialized (not consistent with readonly properties)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Serialization
    • Labels:
      None

      Description

       

      public class B
       {
        public int[] Data { get; private set; }
        public B(int[] data2)
        {
          Data = data2.ToArray();
        }
      }
      

       

      public class A
       {
        public int[] Data { get; }
        public A(int[] data2)
        {
          Data = data2.ToArray();
        }
      }
      

      B b = new B(new[] { 1, 20 });
      A a = new A(new[] { 1, 20 });

      Class B.ToJson results in "{ \"Data\" : [1, 20] }"
      Class A.ToJson results in "{ }"

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            boris.dogadov Boris Dogadov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: