diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index e4c43e83..c3ec43e9 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -8588,6 +8588,28 @@ Path '', line 1, position 1."); Assert.AreEqual("derived", d.DerivedProperty); } + [Test] + public void DeserializeNullableUnsignedLong() + { + NullableLongTestClass instance = new NullableLongTestClass + { + Value = ulong.MaxValue + }; + string output = JsonConvert.SerializeObject(instance); + NullableLongTestClass result = JsonConvert.DeserializeObject(output); + + Assert.AreEqual(ulong.MaxValue, result.Value); + } + + public class NullableLongTestClass + { + public ulong? Value + { + get; + set; + } + } + #if !NETFX_CORE [Test] public void MailMessageConverterTest() diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs index 97d452b5..d3bde687 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs @@ -862,7 +862,7 @@ namespace Newtonsoft.Json.Serialization #if !(PORTABLE || PORTABLE40 || NET35 || NET20) if (value is BigInteger) - return ConvertUtils.FromBigInteger((BigInteger)value, targetType); + return ConvertUtils.FromBigInteger((BigInteger)value, contract.NonNullableUnderlyingType); #endif // this won't work when converting to a custom IConvertible