-Fixed not matching some parameters when deserializing via a cosntructor

This commit is contained in:
James Newton-King
2014-09-02 23:29:20 +12:00
parent 4a375721ac
commit 0c865efd96
4 changed files with 51 additions and 20 deletions
@@ -7611,6 +7611,28 @@ Parameter name: value",
}
#endif
public class FooConstructor
{
[JsonProperty(PropertyName = "something_else")]
public readonly string Bar;
public FooConstructor(string bar)
{
if (bar == null)
throw new ArgumentNullException("bar");
Bar = bar;
}
}
[Test]
public void DeserializeWithConstructor()
{
const string json = @"{""something_else"":""my value""}";
var foo = JsonConvert.DeserializeObject<FooConstructor>(json);
Assert.AreEqual("my value", foo.Bar);
}
[Test]
public void SerializeCustomReferenceResolver()
{