-Fixed writing ULong.MaxValue JValues as JSON
This commit is contained in:
@@ -54,6 +54,38 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
[TestFixture]
|
||||
public class LinqToJsonTest : TestFixtureBase
|
||||
{
|
||||
public class TestClass_ULong
|
||||
{
|
||||
public ulong Value { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FromObject_ULongMaxValue()
|
||||
{
|
||||
TestClass_ULong instance = new TestClass_ULong { Value = ulong.MaxValue };
|
||||
JObject output = JObject.FromObject(instance);
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""Value"": 18446744073709551615
|
||||
}", output.ToString());
|
||||
}
|
||||
|
||||
public class TestClass_Byte
|
||||
{
|
||||
public byte Value { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FromObject_ByteMaxValue()
|
||||
{
|
||||
TestClass_Byte instance = new TestClass_Byte { Value = byte.MaxValue };
|
||||
JObject output = JObject.FromObject(instance);
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""Value"": 255
|
||||
}", output.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToObject_Base64AndGuid()
|
||||
{
|
||||
|
||||
@@ -676,11 +676,17 @@ namespace Newtonsoft.Json.Linq
|
||||
writer.WriteUndefined();
|
||||
return;
|
||||
case JTokenType.Integer:
|
||||
if (_value is int)
|
||||
writer.WriteValue((int)_value);
|
||||
else if (_value is long)
|
||||
writer.WriteValue((long)_value);
|
||||
else if (_value is ulong)
|
||||
writer.WriteValue((ulong)_value);
|
||||
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
|
||||
if (_value is BigInteger)
|
||||
else if (_value is BigInteger)
|
||||
writer.WriteValue((BigInteger)_value);
|
||||
else
|
||||
#endif
|
||||
else
|
||||
writer.WriteValue(Convert.ToInt64(_value, CultureInfo.InvariantCulture));
|
||||
return;
|
||||
case JTokenType.Float:
|
||||
|
||||
Reference in New Issue
Block a user