-Fixed WinRT build
This commit is contained in:
@@ -281,6 +281,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||||
|
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||||
<Compile Include="Utilities\ReflectionUtilsTests.cs" />
|
<Compile Include="Utilities\ReflectionUtilsTests.cs" />
|
||||||
<Compile Include="Utilities\StringUtilsTests.cs" />
|
<Compile Include="Utilities\StringUtilsTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -75,4 +75,4 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("5.0.4.16024")]
|
[assembly: AssemblyFileVersion("5.0.4.16025")]
|
||||||
|
|||||||
@@ -36,5 +36,20 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
public string Studio { get; set; }
|
public string Studio { get; set; }
|
||||||
public DateTime? ReleaseDate { get; set; }
|
public DateTime? ReleaseDate { get; set; }
|
||||||
public List<string> ReleaseCountries { get; set; }
|
public List<string> ReleaseCountries { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return base.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return base.Equals(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return base.GetHashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Tests.Utilities
|
|||||||
[Test]
|
[Test]
|
||||||
public void DefaultConstructor_Abstract()
|
public void DefaultConstructor_Abstract()
|
||||||
{
|
{
|
||||||
ExceptionAssert.Throws<MissingMethodException>("Cannot create an abstract class.",
|
ExceptionAssert.Throws<Exception>("Cannot create an abstract class.",
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
Func<object> create = ExpressionReflectionDelegateFactory.Instance.CreateDefaultConstructor<object>(typeof(Type));
|
Func<object> create = ExpressionReflectionDelegateFactory.Instance.CreateDefaultConstructor<object>(typeof(Type));
|
||||||
|
|||||||
@@ -221,6 +221,7 @@
|
|||||||
<Compile Include="Serialization\DynamicValueProvider.cs" />
|
<Compile Include="Serialization\DynamicValueProvider.cs" />
|
||||||
<Compile Include="Serialization\ErrorContext.cs" />
|
<Compile Include="Serialization\ErrorContext.cs" />
|
||||||
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
||||||
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
<Compile Include="Serialization\IContractResolver.cs" />
|
<Compile Include="Serialization\IContractResolver.cs" />
|
||||||
<Compile Include="Serialization\IReferenceResolver.cs" />
|
<Compile Include="Serialization\IReferenceResolver.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
@@ -269,6 +270,7 @@
|
|||||||
<Compile Include="Utilities\EnumUtils.cs" />
|
<Compile Include="Utilities\EnumUtils.cs" />
|
||||||
<Compile Include="Utilities\EnumValue.cs" />
|
<Compile Include="Utilities\EnumValue.cs" />
|
||||||
<Compile Include="Utilities\EnumValues.cs" />
|
<Compile Include="Utilities\EnumValues.cs" />
|
||||||
|
<Compile Include="Utilities\ExpressionReflectionDelegateFactory.cs" />
|
||||||
<Compile Include="Utilities\ILGeneratorExtensions.cs" />
|
<Compile Include="Utilities\ILGeneratorExtensions.cs" />
|
||||||
<Compile Include="Utilities\JavaScriptUtils.cs" />
|
<Compile Include="Utilities\JavaScriptUtils.cs" />
|
||||||
<Compile Include="Utilities\LateBoundReflectionDelegateFactory.cs" />
|
<Compile Include="Utilities\LateBoundReflectionDelegateFactory.cs" />
|
||||||
|
|||||||
@@ -92,6 +92,6 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("5.0.4.16024")]
|
[assembly: AssemblyFileVersion("5.0.4.16025")]
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|||||||
@@ -362,14 +362,9 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
if (ReadSpecialProperties(reader, ref objectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
if (ReadSpecialProperties(reader, ref objectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
||||||
return newValue;
|
return newValue;
|
||||||
|
|
||||||
if (contract == null || objectType == typeof(object) || objectType == typeof(IDynamicMetaObjectProvider))
|
if (HasNoDefinedType(contract))
|
||||||
{
|
|
||||||
if (!HasDefinedType(objectType))
|
|
||||||
return CreateJObject(reader);
|
return CreateJObject(reader);
|
||||||
|
|
||||||
throw JsonSerializationException.Create(reader, "Could not resolve type '{0}' to a JsonContract.".FormatWith(CultureInfo.InvariantCulture, objectType));
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (contract.ContractType)
|
switch (contract.ContractType)
|
||||||
{
|
{
|
||||||
case JsonContractType.Object:
|
case JsonContractType.Object:
|
||||||
@@ -609,8 +604,10 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
|||||||
private object CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, object existingValue, string id)
|
private object CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, object existingValue, string id)
|
||||||
{
|
{
|
||||||
object value;
|
object value;
|
||||||
if (HasDefinedType(objectType))
|
|
||||||
{
|
if (HasNoDefinedType(contract))
|
||||||
|
return CreateJToken(reader, contract);
|
||||||
|
|
||||||
JsonArrayContract arrayContract = EnsureArrayContract(reader, objectType, contract);
|
JsonArrayContract arrayContract = EnsureArrayContract(reader, objectType, contract);
|
||||||
|
|
||||||
if (existingValue == null)
|
if (existingValue == null)
|
||||||
@@ -661,20 +658,15 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
|||||||
{
|
{
|
||||||
value = PopulateList((arrayContract.ShouldCreateWrapper) ? arrayContract.CreateWrapper(existingValue) : (IList) existingValue, reader, arrayContract, member, id);
|
value = PopulateList((arrayContract.ShouldCreateWrapper) ? arrayContract.CreateWrapper(existingValue) : (IList) existingValue, reader, arrayContract, member, id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
value = CreateJToken(reader, contract);
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasDefinedType(Type type)
|
private bool HasNoDefinedType(JsonContract contract)
|
||||||
{
|
{
|
||||||
return (type != null && type != typeof (object) && !typeof (JToken).IsSubclassOf(type)
|
return (contract == null || contract.UnderlyingType == typeof (object) || contract.ContractType == JsonContractType.Linq
|
||||||
#if !(NET35 || NET20 || PORTABLE40)
|
#if !(NET35 || NET20 || PORTABLE40)
|
||||||
&& type != typeof (IDynamicMetaObjectProvider)
|
|| contract.UnderlyingType == typeof(IDynamicMetaObjectProvider)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1336,7 +1328,7 @@ To fix this error either change the environment to be fully trusted, change the
|
|||||||
{
|
{
|
||||||
IDynamicMetaObjectProvider newObject;
|
IDynamicMetaObjectProvider newObject;
|
||||||
|
|
||||||
if (contract.UnderlyingType.IsInterface() || contract.UnderlyingType.IsAbstract())
|
if (!contract.IsInstantiable)
|
||||||
throw JsonSerializationException.Create(reader, "Could not create an instance of type {0}. Type is an interface or abstract class and cannot be instantiated.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
|
throw JsonSerializationException.Create(reader, "Could not create an instance of type {0}. Type is an interface or abstract class and cannot be instantiated.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
|
||||||
|
|
||||||
if (contract.DefaultCreator != null &&
|
if (contract.DefaultCreator != null &&
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
if (type.IsAbstract())
|
if (type.IsAbstract())
|
||||||
return () => (T)Activator.CreateInstance(type);
|
return () => (T)Activator.CreateInstance(type);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
Type resultType = typeof(T);
|
Type resultType = typeof(T);
|
||||||
|
|
||||||
Expression expression = Expression.New(type);
|
Expression expression = Expression.New(type);
|
||||||
@@ -107,6 +109,13 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
Func<T> compiled = (Func<T>)lambdaExpression.Compile();
|
Func<T> compiled = (Func<T>)lambdaExpression.Compile();
|
||||||
return compiled;
|
return compiled;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// an error can be thrown if constructor is not valid on Win8
|
||||||
|
// will have INVOCATION_FLAGS_NON_W8P_FX_API invocation flag
|
||||||
|
return () => (T)Activator.CreateInstance(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user