diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index bee8774b..634dd714 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -4277,5 +4277,38 @@ keyword such as type of business."" Assert.AreEqual(1939, commentTestClass.StartYear); Assert.AreEqual(63, commentTestClass.Values.Count); } + + class DTOWithParameterisedConstructor + { + public DTOWithParameterisedConstructor(string A) + { + this.A = A; + B = 2; + } + + public string A { get; set; } + public int? B { get; set; } + } + + class DTOWithoutParameterisedConstructor + { + public DTOWithoutParameterisedConstructor() + { + B = 2; + } + + public string A { get; set; } + public int? B { get; set; } + } + + [Test] + public void PopulationBehaviourForOmittedPropertiesIsTheSameForParameterisedConstructorAsForDefaultConstructor() + { + string json = @"{A:""Test""}"; + + var withoutParameterisedConstructor = JsonConvert.DeserializeObject(json); + var withParameterisedConstructor = JsonConvert.DeserializeObject(json); + Assert.AreEqual(withoutParameterisedConstructor.B, withParameterisedConstructor.B); + } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs index 97b41b52..1ac9ee38 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs @@ -865,8 +865,7 @@ namespace Newtonsoft.Json.Serialization Type objectType = contract.UnderlyingType; - // create a dictionary to put retrieved values into - IDictionary propertyValues = contract.Properties.Where(p => !p.Ignored).ToDictionary(kv => kv, kv => (object)null); + IDictionary propertyValues = new Dictionary(); bool exit = false; do