I know every guideline says you should not inherit from list. I also realize there's not much sense in putting extra properties into such inherited type, instead they should be stored in the class which stores this collection internally. But imagine I absolutely have to.
Example of data structure:
public class Gen<TType> : List<TType>
{
public int SomeValue { get; set; }
public string Name { get; set; }
}
public class RootObject<TType>
{
public int X { get; set; }
public Gen<TType> Items { get; set; }
}
var message = new RootObject<SomeClass>()
{
X = 31,
Items = new Gen<SomeClass>() { SomeValue = 22, Name = "name" }
};
Is there a way to serialize it without losing values of Gen<> specific properties (the "SomeValue" and "Name" ones)?
I'm using Newtonsoft.Json serializer.