Merge pull request #918 from taylorwood/typo
Fix spelling of "parameterized"
This commit is contained in:
@@ -170,15 +170,15 @@
|
|||||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||||
|
|||||||
@@ -201,12 +201,12 @@
|
|||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PersonError.cs" />
|
<Compile Include="TestObjects\PersonError.cs" />
|
||||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\Content.cs" />
|
<Compile Include="TestObjects\Content.cs" />
|
||||||
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
||||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||||
@@ -231,8 +231,8 @@
|
|||||||
<Compile Include="TestObjects\LogEntry.cs" />
|
<Compile Include="TestObjects\LogEntry.cs" />
|
||||||
<Compile Include="TestObjects\NonRequest.cs" />
|
<Compile Include="TestObjects\NonRequest.cs" />
|
||||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||||
<Compile Include="TestObjects\SearchResult.cs" />
|
<Compile Include="TestObjects\SearchResult.cs" />
|
||||||
|
|||||||
@@ -317,7 +317,7 @@
|
|||||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\Content.cs" />
|
<Compile Include="TestObjects\Content.cs" />
|
||||||
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
||||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||||
@@ -345,10 +345,10 @@
|
|||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||||
<Compile Include="TestObjects\SearchResult.cs" />
|
<Compile Include="TestObjects\SearchResult.cs" />
|
||||||
|
|||||||
@@ -192,7 +192,7 @@
|
|||||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\Content.cs" />
|
<Compile Include="TestObjects\Content.cs" />
|
||||||
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
||||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||||
@@ -220,10 +220,10 @@
|
|||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||||
<Compile Include="TestObjects\SearchResult.cs" />
|
<Compile Include="TestObjects\SearchResult.cs" />
|
||||||
|
|||||||
@@ -196,7 +196,7 @@
|
|||||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\Content.cs" />
|
<Compile Include="TestObjects\Content.cs" />
|
||||||
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
||||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||||
@@ -224,10 +224,10 @@
|
|||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||||
<Compile Include="TestObjects\SearchResult.cs" />
|
<Compile Include="TestObjects\SearchResult.cs" />
|
||||||
|
|||||||
@@ -382,7 +382,7 @@
|
|||||||
<Compile Include="TestObjects\PhoneNumber.cs" />
|
<Compile Include="TestObjects\PhoneNumber.cs" />
|
||||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||||
<Compile Include="TestObjects\PrivateMembersClass.cs" />
|
<Compile Include="TestObjects\PrivateMembersClass.cs" />
|
||||||
@@ -391,10 +391,10 @@
|
|||||||
<Compile Include="TestObjects\ProductShort.cs" />
|
<Compile Include="TestObjects\ProductShort.cs" />
|
||||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
|
||||||
<Compile Include="TestObjects\Ratio.cs" />
|
<Compile Include="TestObjects\Ratio.cs" />
|
||||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||||
<Compile Include="TestObjects\RequiredMembersClass.cs" />
|
<Compile Include="TestObjects\RequiredMembersClass.cs" />
|
||||||
|
|||||||
@@ -77,22 +77,22 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void FailWithPrivateConstructorPlusParametizedAndDefault()
|
public void FailWithPrivateConstructorPlusParameterizedAndDefault()
|
||||||
{
|
{
|
||||||
ExceptionAssert.Throws<Exception>(() =>
|
ExceptionAssert.Throws<Exception>(() =>
|
||||||
{
|
{
|
||||||
string json = @"{Name:""Name!""}";
|
string json = @"{Name:""Name!""}";
|
||||||
|
|
||||||
PrivateConstructorWithPublicParametizedConstructorTestClass c = JsonConvert.DeserializeObject<PrivateConstructorWithPublicParametizedConstructorTestClass>(json);
|
PrivateConstructorWithPublicParameterizedConstructorTestClass c = JsonConvert.DeserializeObject<PrivateConstructorWithPublicParameterizedConstructorTestClass>(json);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPrivateConstructorPlusParametizedAndAllowNonPublic()
|
public void SuccessWithPrivateConstructorPlusParameterizedAndAllowNonPublic()
|
||||||
{
|
{
|
||||||
string json = @"{Name:""Name!""}";
|
string json = @"{Name:""Name!""}";
|
||||||
|
|
||||||
PrivateConstructorWithPublicParametizedConstructorTestClass c = JsonConvert.DeserializeObject<PrivateConstructorWithPublicParametizedConstructorTestClass>(json,
|
PrivateConstructorWithPublicParameterizedConstructorTestClass c = JsonConvert.DeserializeObject<PrivateConstructorWithPublicParameterizedConstructorTestClass>(json,
|
||||||
new JsonSerializerSettings
|
new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
|
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
|
||||||
@@ -103,71 +103,71 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructor()
|
public void SuccessWithPublicParameterizedConstructor()
|
||||||
{
|
{
|
||||||
string json = @"{Name:""Name!""}";
|
string json = @"{Name:""Name!""}";
|
||||||
|
|
||||||
var c = JsonConvert.DeserializeObject<PublicParametizedConstructorTestClass>(json);
|
var c = JsonConvert.DeserializeObject<PublicParameterizedConstructorTestClass>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual("Name!", c.Name);
|
Assert.AreEqual("Name!", c.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructorWhenParamaterIsNotAProperty()
|
public void SuccessWithPublicParameterizedConstructorWhenParameterIsNotAProperty()
|
||||||
{
|
{
|
||||||
string json = @"{nameParameter:""Name!""}";
|
string json = @"{nameParameter:""Name!""}";
|
||||||
|
|
||||||
PublicParametizedConstructorWithNonPropertyParameterTestClass c = JsonConvert.DeserializeObject<PublicParametizedConstructorWithNonPropertyParameterTestClass>(json);
|
PublicParameterizedConstructorWithNonPropertyParameterTestClass c = JsonConvert.DeserializeObject<PublicParameterizedConstructorWithNonPropertyParameterTestClass>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual("Name!", c.Name);
|
Assert.AreEqual("Name!", c.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructorWhenParamaterRequiresAConverter()
|
public void SuccessWithPublicParameterizedConstructorWhenParameterRequiresAConverter()
|
||||||
{
|
{
|
||||||
string json = @"{nameParameter:""Name!""}";
|
string json = @"{nameParameter:""Name!""}";
|
||||||
|
|
||||||
PublicParametizedConstructorRequiringConverterTestClass c = JsonConvert.DeserializeObject<PublicParametizedConstructorRequiringConverterTestClass>(json, new NameContainerConverter());
|
PublicParameterizedConstructorRequiringConverterTestClass c = JsonConvert.DeserializeObject<PublicParameterizedConstructorRequiringConverterTestClass>(json, new NameContainerConverter());
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual("Name!", c.Name.Value);
|
Assert.AreEqual("Name!", c.Name.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructorWhenParamaterRequiresAConverterWithParameterAttribute()
|
public void SuccessWithPublicParameterizedConstructorWhenParameterRequiresAConverterWithParameterAttribute()
|
||||||
{
|
{
|
||||||
string json = @"{nameParameter:""Name!""}";
|
string json = @"{nameParameter:""Name!""}";
|
||||||
|
|
||||||
PublicParametizedConstructorRequiringConverterWithParameterAttributeTestClass c = JsonConvert.DeserializeObject<PublicParametizedConstructorRequiringConverterWithParameterAttributeTestClass>(json);
|
PublicParameterizedConstructorRequiringConverterWithParameterAttributeTestClass c = JsonConvert.DeserializeObject<PublicParameterizedConstructorRequiringConverterWithParameterAttributeTestClass>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual("Name!", c.Name.Value);
|
Assert.AreEqual("Name!", c.Name.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructorWhenParamaterRequiresAConverterWithPropertyAttribute()
|
public void SuccessWithPublicParameterizedConstructorWhenParameterRequiresAConverterWithPropertyAttribute()
|
||||||
{
|
{
|
||||||
string json = @"{name:""Name!""}";
|
string json = @"{name:""Name!""}";
|
||||||
|
|
||||||
PublicParametizedConstructorRequiringConverterWithPropertyAttributeTestClass c = JsonConvert.DeserializeObject<PublicParametizedConstructorRequiringConverterWithPropertyAttributeTestClass>(json);
|
PublicParameterizedConstructorRequiringConverterWithPropertyAttributeTestClass c = JsonConvert.DeserializeObject<PublicParameterizedConstructorRequiringConverterWithPropertyAttributeTestClass>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual("Name!", c.Name.Value);
|
Assert.AreEqual("Name!", c.Name.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuccessWithPublicParametizedConstructorWhenParamaterNameConflictsWithPropertyName()
|
public void SuccessWithPublicParameterizedConstructorWhenParameterNameConflictsWithPropertyName()
|
||||||
{
|
{
|
||||||
string json = @"{name:""1""}";
|
string json = @"{name:""1""}";
|
||||||
|
|
||||||
PublicParametizedConstructorWithPropertyNameConflict c = JsonConvert.DeserializeObject<PublicParametizedConstructorWithPropertyNameConflict>(json);
|
PublicParameterizedConstructorWithPropertyNameConflict c = JsonConvert.DeserializeObject<PublicParameterizedConstructorWithPropertyNameConflict>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual(1, c.Name);
|
Assert.AreEqual(1, c.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PublicParametizedConstructorWithPropertyNameConflictWithAttribute()
|
public void PublicParameterizedConstructorWithPropertyNameConflictWithAttribute()
|
||||||
{
|
{
|
||||||
string json = @"{name:""1""}";
|
string json = @"{name:""1""}";
|
||||||
|
|
||||||
PublicParametizedConstructorWithPropertyNameConflictWithAttribute c = JsonConvert.DeserializeObject<PublicParametizedConstructorWithPropertyNameConflictWithAttribute>(json);
|
PublicParameterizedConstructorWithPropertyNameConflictWithAttribute c = JsonConvert.DeserializeObject<PublicParameterizedConstructorWithPropertyNameConflictWithAttribute>(json);
|
||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual(1, c.Name);
|
Assert.AreEqual(1, c.Name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,12 +441,12 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
public void ParameterizedCreator()
|
public void ParameterizedCreator()
|
||||||
{
|
{
|
||||||
var resolver = new DefaultContractResolver();
|
var resolver = new DefaultContractResolver();
|
||||||
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(PublicParametizedConstructorWithPropertyNameConflictWithAttribute));
|
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(PublicParameterizedConstructorWithPropertyNameConflictWithAttribute));
|
||||||
|
|
||||||
Assert.IsNull(contract.DefaultCreator);
|
Assert.IsNull(contract.DefaultCreator);
|
||||||
Assert.IsNotNull(contract.ParameterizedCreator);
|
Assert.IsNotNull(contract.ParameterizedCreator);
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
Assert.AreEqual(contract.ParametrizedConstructor, typeof(PublicParametizedConstructorWithPropertyNameConflictWithAttribute).GetConstructor(new[] { typeof(string) }));
|
Assert.AreEqual(contract.ParametrizedConstructor, typeof(PublicParameterizedConstructorWithPropertyNameConflictWithAttribute).GetConstructor(new[] { typeof(string) }));
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
Assert.AreEqual(1, contract.CreatorParameters.Count);
|
Assert.AreEqual(1, contract.CreatorParameters.Count);
|
||||||
Assert.AreEqual("name", contract.CreatorParameters[0].PropertyName);
|
Assert.AreEqual("name", contract.CreatorParameters[0].PropertyName);
|
||||||
@@ -461,12 +461,12 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
public void OverrideCreator()
|
public void OverrideCreator()
|
||||||
{
|
{
|
||||||
var resolver = new DefaultContractResolver();
|
var resolver = new DefaultContractResolver();
|
||||||
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(MultipleParamatrizedConstructorsJsonConstructor));
|
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(MultipleParametrizedConstructorsJsonConstructor));
|
||||||
|
|
||||||
Assert.IsNull(contract.DefaultCreator);
|
Assert.IsNull(contract.DefaultCreator);
|
||||||
Assert.IsNotNull(contract.OverrideCreator);
|
Assert.IsNotNull(contract.OverrideCreator);
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
Assert.AreEqual(contract.OverrideConstructor, typeof(MultipleParamatrizedConstructorsJsonConstructor).GetConstructor(new[] { typeof(string), typeof(int) }));
|
Assert.AreEqual(contract.OverrideConstructor, typeof(MultipleParametrizedConstructorsJsonConstructor).GetConstructor(new[] { typeof(string), typeof(int) }));
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
Assert.AreEqual(2, contract.CreatorParameters.Count);
|
Assert.AreEqual(2, contract.CreatorParameters.Count);
|
||||||
Assert.AreEqual("Value", contract.CreatorParameters[0].PropertyName);
|
Assert.AreEqual("Value", contract.CreatorParameters[0].PropertyName);
|
||||||
@@ -482,20 +482,20 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
public void CustomOverrideCreator()
|
public void CustomOverrideCreator()
|
||||||
{
|
{
|
||||||
var resolver = new DefaultContractResolver();
|
var resolver = new DefaultContractResolver();
|
||||||
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(MultipleParamatrizedConstructorsJsonConstructor));
|
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(MultipleParametrizedConstructorsJsonConstructor));
|
||||||
|
|
||||||
bool ensureCustomCreatorCalled = false;
|
bool ensureCustomCreatorCalled = false;
|
||||||
|
|
||||||
contract.OverrideCreator = args =>
|
contract.OverrideCreator = args =>
|
||||||
{
|
{
|
||||||
ensureCustomCreatorCalled = true;
|
ensureCustomCreatorCalled = true;
|
||||||
return new MultipleParamatrizedConstructorsJsonConstructor((string)args[0], (int)args[1]);
|
return new MultipleParametrizedConstructorsJsonConstructor((string)args[0], (int)args[1]);
|
||||||
};
|
};
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
Assert.IsNull(contract.OverrideConstructor);
|
Assert.IsNull(contract.OverrideConstructor);
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
|
|
||||||
var o = JsonConvert.DeserializeObject<MultipleParamatrizedConstructorsJsonConstructor>("{Value:'value!', Age:1}", new JsonSerializerSettings
|
var o = JsonConvert.DeserializeObject<MultipleParametrizedConstructorsJsonConstructor>("{Value:'value!', Age:1}", new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
ContractResolver = resolver
|
ContractResolver = resolver
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6104,15 +6104,15 @@ Path '', line 1, position 1.");
|
|||||||
public void PublicConstructorOverridenByJsonConstructorTest()
|
public void PublicConstructorOverridenByJsonConstructorTest()
|
||||||
{
|
{
|
||||||
PublicConstructorOverridenByJsonConstructor c = JsonConvert.DeserializeObject<PublicConstructorOverridenByJsonConstructor>("{Value:'value!'}");
|
PublicConstructorOverridenByJsonConstructor c = JsonConvert.DeserializeObject<PublicConstructorOverridenByJsonConstructor>("{Value:'value!'}");
|
||||||
Assert.AreEqual("Public Paramatized", c.Constructor);
|
Assert.AreEqual("Public Parameterized", c.Constructor);
|
||||||
Assert.AreEqual("value!", c.Value);
|
Assert.AreEqual("value!", c.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void MultipleParamatrizedConstructorsJsonConstructorTest()
|
public void MultipleParametrizedConstructorsJsonConstructorTest()
|
||||||
{
|
{
|
||||||
MultipleParamatrizedConstructorsJsonConstructor c = JsonConvert.DeserializeObject<MultipleParamatrizedConstructorsJsonConstructor>("{Value:'value!', Age:1}");
|
MultipleParametrizedConstructorsJsonConstructor c = JsonConvert.DeserializeObject<MultipleParametrizedConstructorsJsonConstructor>("{Value:'value!', Age:1}");
|
||||||
Assert.AreEqual("Public Paramatized 2", c.Constructor);
|
Assert.AreEqual("Public Parameterized 2", c.Constructor);
|
||||||
Assert.AreEqual("value!", c.Value);
|
Assert.AreEqual("value!", c.Value);
|
||||||
Assert.AreEqual(1, c.Age);
|
Assert.AreEqual(1, c.Age);
|
||||||
}
|
}
|
||||||
@@ -9760,7 +9760,7 @@ Path '', line 1, position 1.");
|
|||||||
public NonPublicConstructorWithJsonConstructor(string value)
|
public NonPublicConstructorWithJsonConstructor(string value)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
Constructor = "Public Paramatized";
|
Constructor = "Public Parameterized";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9803,28 +9803,28 @@ Path '', line 1, position 1.");
|
|||||||
public PublicConstructorOverridenByJsonConstructor(string value)
|
public PublicConstructorOverridenByJsonConstructor(string value)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
Constructor = "Public Paramatized";
|
Constructor = "Public Parameterized";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MultipleParamatrizedConstructorsJsonConstructor
|
public class MultipleParametrizedConstructorsJsonConstructor
|
||||||
{
|
{
|
||||||
public string Value { get; private set; }
|
public string Value { get; private set; }
|
||||||
public int Age { get; private set; }
|
public int Age { get; private set; }
|
||||||
public string Constructor { get; private set; }
|
public string Constructor { get; private set; }
|
||||||
|
|
||||||
public MultipleParamatrizedConstructorsJsonConstructor(string value)
|
public MultipleParametrizedConstructorsJsonConstructor(string value)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
Constructor = "Public Paramatized 1";
|
Constructor = "Public Parameterized 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public MultipleParamatrizedConstructorsJsonConstructor(string value, int age)
|
public MultipleParametrizedConstructorsJsonConstructor(string value, int age)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
Age = age;
|
Age = age;
|
||||||
Constructor = "Public Paramatized 2";
|
Constructor = "Public Parameterized 2";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -733,7 +733,7 @@ Newtonsoft.Json Error: 0 : Error!
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PublicParametizedConstructorWithPropertyNameConflictWithAttribute()
|
public void PublicParameterizedConstructorWithPropertyNameConflictWithAttribute()
|
||||||
{
|
{
|
||||||
InMemoryTraceWriter traceWriter = new InMemoryTraceWriter
|
InMemoryTraceWriter traceWriter = new InMemoryTraceWriter
|
||||||
{
|
{
|
||||||
@@ -742,7 +742,7 @@ Newtonsoft.Json Error: 0 : Error!
|
|||||||
|
|
||||||
string json = @"{name:""1""}";
|
string json = @"{name:""1""}";
|
||||||
|
|
||||||
PublicParametizedConstructorWithPropertyNameConflictWithAttribute c = JsonConvert.DeserializeObject<PublicParametizedConstructorWithPropertyNameConflictWithAttribute>(json, new JsonSerializerSettings
|
PublicParameterizedConstructorWithPropertyNameConflictWithAttribute c = JsonConvert.DeserializeObject<PublicParameterizedConstructorWithPropertyNameConflictWithAttribute>(json, new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
TraceWriter = traceWriter
|
TraceWriter = traceWriter
|
||||||
});
|
});
|
||||||
@@ -750,7 +750,7 @@ Newtonsoft.Json Error: 0 : Error!
|
|||||||
Assert.IsNotNull(c);
|
Assert.IsNotNull(c);
|
||||||
Assert.AreEqual(1, c.Name);
|
Assert.AreEqual(1, c.Name);
|
||||||
|
|
||||||
Assert.AreEqual("Deserializing Newtonsoft.Json.Tests.TestObjects.PublicParametizedConstructorWithPropertyNameConflictWithAttribute using creator with parameters: name. Path 'name', line 1, position 6.", traceWriter.TraceRecords[0].Message);
|
Assert.AreEqual("Deserializing Newtonsoft.Json.Tests.TestObjects.PublicParameterizedConstructorWithPropertyNameConflictWithAttribute using creator with parameters: name. Path 'name', line 1, position 6.", traceWriter.TraceRecords[0].Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
+3
-3
@@ -27,17 +27,17 @@ using System;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.TestObjects
|
namespace Newtonsoft.Json.Tests.TestObjects
|
||||||
{
|
{
|
||||||
public class PrivateConstructorWithPublicParametizedConstructorTestClass
|
public class PrivateConstructorWithPublicParameterizedConstructorTestClass
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Age { get; set; }
|
public int Age { get; set; }
|
||||||
|
|
||||||
private PrivateConstructorWithPublicParametizedConstructorTestClass()
|
private PrivateConstructorWithPublicParameterizedConstructorTestClass()
|
||||||
{
|
{
|
||||||
Age = 1;
|
Age = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrivateConstructorWithPublicParametizedConstructorTestClass(string dummy)
|
public PrivateConstructorWithPublicParameterizedConstructorTestClass(string dummy)
|
||||||
{
|
{
|
||||||
throw new Exception("Should never get here.");
|
throw new Exception("Should never get here.");
|
||||||
}
|
}
|
||||||
+6
-6
@@ -62,11 +62,11 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublicParametizedConstructorRequiringConverterTestClass
|
public class PublicParameterizedConstructorRequiringConverterTestClass
|
||||||
{
|
{
|
||||||
private readonly NameContainer _nameContainer;
|
private readonly NameContainer _nameContainer;
|
||||||
|
|
||||||
public PublicParametizedConstructorRequiringConverterTestClass(NameContainer nameParameter)
|
public PublicParameterizedConstructorRequiringConverterTestClass(NameContainer nameParameter)
|
||||||
{
|
{
|
||||||
_nameContainer = nameParameter;
|
_nameContainer = nameParameter;
|
||||||
}
|
}
|
||||||
@@ -77,11 +77,11 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublicParametizedConstructorRequiringConverterWithParameterAttributeTestClass
|
public class PublicParameterizedConstructorRequiringConverterWithParameterAttributeTestClass
|
||||||
{
|
{
|
||||||
private readonly NameContainer _nameContainer;
|
private readonly NameContainer _nameContainer;
|
||||||
|
|
||||||
public PublicParametizedConstructorRequiringConverterWithParameterAttributeTestClass([JsonConverter(typeof(NameContainerConverter))] NameContainer nameParameter)
|
public PublicParameterizedConstructorRequiringConverterWithParameterAttributeTestClass([JsonConverter(typeof(NameContainerConverter))] NameContainer nameParameter)
|
||||||
{
|
{
|
||||||
_nameContainer = nameParameter;
|
_nameContainer = nameParameter;
|
||||||
}
|
}
|
||||||
@@ -92,11 +92,11 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublicParametizedConstructorRequiringConverterWithPropertyAttributeTestClass
|
public class PublicParameterizedConstructorRequiringConverterWithPropertyAttributeTestClass
|
||||||
{
|
{
|
||||||
private readonly NameContainer _nameContainer;
|
private readonly NameContainer _nameContainer;
|
||||||
|
|
||||||
public PublicParametizedConstructorRequiringConverterWithPropertyAttributeTestClass(NameContainer name)
|
public PublicParameterizedConstructorRequiringConverterWithPropertyAttributeTestClass(NameContainer name)
|
||||||
{
|
{
|
||||||
_nameContainer = name;
|
_nameContainer = name;
|
||||||
}
|
}
|
||||||
+2
-2
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.TestObjects
|
namespace Newtonsoft.Json.Tests.TestObjects
|
||||||
{
|
{
|
||||||
public class PublicParametizedConstructorTestClass
|
public class PublicParameterizedConstructorTestClass
|
||||||
{
|
{
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
public PublicParametizedConstructorTestClass(string name)
|
public PublicParameterizedConstructorTestClass(string name)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
}
|
}
|
||||||
+2
-2
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.TestObjects
|
namespace Newtonsoft.Json.Tests.TestObjects
|
||||||
{
|
{
|
||||||
public class PublicParametizedConstructorWithNonPropertyParameterTestClass
|
public class PublicParameterizedConstructorWithNonPropertyParameterTestClass
|
||||||
{
|
{
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
public PublicParametizedConstructorWithNonPropertyParameterTestClass(string nameParameter)
|
public PublicParameterizedConstructorWithNonPropertyParameterTestClass(string nameParameter)
|
||||||
{
|
{
|
||||||
_name = nameParameter;
|
_name = nameParameter;
|
||||||
}
|
}
|
||||||
+4
-4
@@ -27,11 +27,11 @@ using System;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.TestObjects
|
namespace Newtonsoft.Json.Tests.TestObjects
|
||||||
{
|
{
|
||||||
public class PublicParametizedConstructorWithPropertyNameConflict
|
public class PublicParameterizedConstructorWithPropertyNameConflict
|
||||||
{
|
{
|
||||||
private readonly int _value;
|
private readonly int _value;
|
||||||
|
|
||||||
public PublicParametizedConstructorWithPropertyNameConflict(string name)
|
public PublicParameterizedConstructorWithPropertyNameConflict(string name)
|
||||||
{
|
{
|
||||||
_value = Convert.ToInt32(name);
|
_value = Convert.ToInt32(name);
|
||||||
}
|
}
|
||||||
@@ -42,11 +42,11 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublicParametizedConstructorWithPropertyNameConflictWithAttribute
|
public class PublicParameterizedConstructorWithPropertyNameConflictWithAttribute
|
||||||
{
|
{
|
||||||
private readonly int _value;
|
private readonly int _value;
|
||||||
|
|
||||||
public PublicParametizedConstructorWithPropertyNameConflictWithAttribute([JsonProperty("name")] string nameParameter)
|
public PublicParameterizedConstructorWithPropertyNameConflictWithAttribute([JsonProperty("name")] string nameParameter)
|
||||||
{
|
{
|
||||||
_value = Convert.ToInt32(nameParameter);
|
_value = Convert.ToInt32(nameParameter);
|
||||||
}
|
}
|
||||||
@@ -31,12 +31,12 @@ namespace Newtonsoft.Json
|
|||||||
public enum ConstructorHandling
|
public enum ConstructorHandling
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// First attempt to use the public default constructor, then fall back to single paramatized constructor, then the non-public default constructor.
|
/// First attempt to use the public default constructor, then fall back to single parameterized constructor, then the non-public default constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Default = 0,
|
Default = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Json.NET will use a non-public default constructor before falling back to a paramatized constructor.
|
/// Json.NET will use a non-public default constructor before falling back to a parameterized constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AllowNonPublicDefaultConstructor = 1
|
AllowNonPublicDefaultConstructor = 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user