diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs index 1cee6b3f..124b5636 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs @@ -186,7 +186,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.IsFalse(contract.IsInstantiable); Assert.IsNull(contract.DefaultCreator); - Assert.IsNull(contract.ParametrizedCreator); + Assert.IsFalse(contract.HasParametrizedCreator); ExceptionAssert.Throws( "Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractListTestClass`1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path '', line 1, position 1.", @@ -268,7 +268,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.IsFalse(contract.IsInstantiable); Assert.IsNull(contract.DefaultCreator); - Assert.IsNull(contract.ParametrizedCreator); + Assert.IsFalse(contract.HasParametrizedCreator); ExceptionAssert.Throws( "Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractDictionaryTestClass`2[System.String,System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'key1', line 1, position 6.", diff --git a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs index e5f540be..cc9d89ae 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs @@ -75,12 +75,7 @@ namespace Newtonsoft.Json.Serialization get { if (_parametrizedCreator == null) - { - if (_parametrizedConstructor == null) - return null; - _parametrizedCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateParametrizedConstructor(_parametrizedConstructor); - } return _parametrizedCreator; } @@ -158,7 +153,7 @@ namespace Newtonsoft.Json.Serialization _genericCollectionDefinitionType = typeof(List<>).MakeGenericType(CollectionItemType); _parametrizedConstructor = CollectionUtils.ResolveEnumerableCollectionConstructor(CreatedType, CollectionItemType); IsReadOnlyOrFixedSize = true; - canDeserialize = (ParametrizedCreator != null); + canDeserialize = HasParametrizedCreator; } #endif else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IEnumerable<>), out tempCollectionType)) @@ -171,7 +166,7 @@ namespace Newtonsoft.Json.Serialization _parametrizedConstructor = CollectionUtils.ResolveEnumerableCollectionConstructor(underlyingType, CollectionItemType); #if !(NET35 || NET20 || NETFX_CORE) - if (ParametrizedCreator == null && underlyingType.Name == FSharpUtils.FSharpListTypeName) + if (!HasParametrizedCreator && underlyingType.Name == FSharpUtils.FSharpListTypeName) { FSharpUtils.EnsureInitialized(underlyingType.Assembly()); _parametrizedCreator = FSharpUtils.CreateSeq(CollectionItemType); @@ -192,7 +187,7 @@ namespace Newtonsoft.Json.Serialization IsReadOnlyOrFixedSize = true; ShouldCreateWrapper = true; - canDeserialize = (ParametrizedCreator != null); + canDeserialize = HasParametrizedCreator; } } else diff --git a/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs b/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs index 5da22eb3..191fec2f 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs @@ -78,12 +78,7 @@ namespace Newtonsoft.Json.Serialization get { if (_parametrizedCreator == null) - { - if (_parametrizedConstructor == null) - return null; - _parametrizedCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateParametrizedConstructor(_parametrizedConstructor); - } return _parametrizedCreator; } @@ -143,7 +138,7 @@ namespace Newtonsoft.Json.Serialization _parametrizedConstructor = CollectionUtils.ResolveEnumerableCollectionConstructor(CreatedType, typeof(KeyValuePair<,>).MakeGenericType(keyType, valueType)); #if !(NET35 || NET20 || NETFX_CORE) - if (_parametrizedConstructor == null && underlyingType.Name == FSharpUtils.FSharpMapTypeName) + if (!HasParametrizedCreator && underlyingType.Name == FSharpUtils.FSharpMapTypeName) { FSharpUtils.EnsureInitialized(underlyingType.Assembly()); _parametrizedCreator = FSharpUtils.CreateMap(keyType, valueType);