-Fixed DataContractAttribute not forcing object serialization of classes

This commit is contained in:
James Newton-King
2018-02-02 16:14:41 +13:00
parent c90e6e871a
commit e9e2d006a5
2 changed files with 128 additions and 0 deletions
@@ -1174,6 +1174,15 @@ namespace Newtonsoft.Json.Serialization
return CreateDictionaryContract(objectType);
}
#if HAVE_DATA_CONTRACTS
// don't use GetDataContractAttribute because it looks for the attribute on base classes
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetCachedAttribute<DataContractAttribute>(objectType);
if (dataContractAttribute != null)
{
return CreateObjectContract(objectType);
}
#endif
if (t == typeof(JToken) || t.IsSubclassOf(typeof(JToken)))
{
return CreateLinqContract(objectType);