How should I serialize my derived class correctly?
to serialize your derived class correctly you should do something like this
[DataContract]
public class MyReadOnlyCollection<T>:ReadOnlyCollection<T>
{
public MyReadOnlyCollection(IList<T> list) : base(list)
{
}
}
EDIT
You cannot use [CollectionDataContract]
because it does not fully meet collection type requirements as the Add method is missing so the type is not considered as a collection type
For more information Collection Types in Data Contracts