How to serialize / deserialize immutable list type in c#
If I have a class defined [DataContract()] class MyObject { [DataMember()] ImmutableList<string> Strings { get; private set} } The ImmutableList<T> type comes from the immutables library https://www.nuget.org/packages/Microsoft.Bcl.Immutable . Note that the class ImmutableList does not have a default constructor or a mutable Add method. Adding things to the list take the form. myList = myList.Add("new string"); Can I add some custom support to the .NET serialization mechanism to support this type and show it how to deserialize it? Currently the collection is just skipped on deserialization