This is a reminder of one reason why we keep Newtonsoft.Json and do not move over to System.Text.Json.
Deserializing collections without setters work with Newtonsoft.Json but not out of the box with System.Text.Json. With System.Text.Json, custom converters are needed.
public virtual IList<SomeObject> Objects { get; } = new List<SomeObject>();
To get it to work with System.Text.Json without custom converters we need:
public virtual IList<SomeObject> Objects { get; set; } = new List<SomeObject>();
Using the latter with analyzers enabled you need to suppress:
[SuppressMessage("Usage", "CA2227:Collection properties should be read only")]
public virtual IList<SomeObject> Objects { get; set; } = new List<SomeObject>();
This is a reminder of one reason why we keep Newtonsoft.Json and do not move over to System.Text.Json.
Deserializing collections without setters work with Newtonsoft.Json but not out of the box with System.Text.Json. With System.Text.Json, custom converters are needed.
https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to#add-to-collections-without-setters
Eg:
To get it to work with System.Text.Json without custom converters we need:
Using the latter with analyzers enabled you need to suppress:
[SuppressMessage("Usage", "CA2227:Collection properties should be read only")] public virtual IList<SomeObject> Objects { get; set; } = new List<SomeObject>();