This project has moved. For the latest updates, please go here.

DataContract attribute incorrectly inherited


There was a discussion for this here

A type deriving from a type decorated with the [DataContract] attribute causes Json.NET to assume opt in serialization for the deriving type despite the attribute being intended to not be inherited.

From MSDN on DataContract:

[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum, Inherited = false, AllowMultiple = false)]
public sealed class DataContractAttribute : Attribute


johnhomes wrote Mar 5, 2016 at 5:45 AM

You need to put KnownType attribute on Manager:
public class Manager
public BigBase[] enemies;
Because it's the Manager which has an array of BigBase whose elements might be the derived classes as well. So the DataContractSerializer will know what to expect from the array when serializing and deserializing Manager object (and it's all DataMember).
JSON Developer