-Fixed serializing discriminated unions with type name or reference tracking enabled
-Fixed build
This commit is contained in:
@@ -23,11 +23,11 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50)
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using Microsoft.FSharp.Core;
|
||||
using Microsoft.FSharp.Reflection;
|
||||
#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -283,6 +283,28 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<Currency>(@"{""Case123"":""AUD""}"), "Unexpected property 'Case123' found when reading union. Path 'Case123', line 1, position 11.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeUnionWithTypeNameHandlingAndReferenceTracking()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(Shape.NewRectangle(10.0, 5.0), new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
TypeNameHandling = TypeNameHandling.All
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
|
||||
Assert.AreEqual(@"{""Case"":""Rectangle"",""Fields"":[10.0,5.0]}", json);
|
||||
|
||||
Shape c = JsonConvert.DeserializeObject<Shape>(json);
|
||||
Assert.AreEqual(true, c.IsRectangle);
|
||||
|
||||
Shape.Rectangle r = (Shape.Rectangle)c;
|
||||
|
||||
Assert.AreEqual(5.0, r.length);
|
||||
Assert.AreEqual(10.0, r.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -76,4 +76,4 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("7.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("7.0.1.18304")]
|
||||
[assembly: AssemblyFileVersion("7.0.1.18321")]
|
||||
|
||||
@@ -57,9 +57,9 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
private readonly char _startingWithChar;
|
||||
|
||||
public DynamicContractResolver(char startingWithChar)
|
||||
#pragma warning disable 612
|
||||
#pragma warning disable 612,618
|
||||
: base(false)
|
||||
#pragma warning restore 612
|
||||
#pragma warning restore 612,618
|
||||
{
|
||||
_startingWithChar = startingWithChar;
|
||||
}
|
||||
|
||||
@@ -3879,6 +3879,7 @@ Path '', line 1, position 1.");
|
||||
}", json);
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
public class DateTimeOffsetWrapper
|
||||
{
|
||||
public DateTimeOffset DateTimeOffsetValue { get; set; }
|
||||
@@ -3907,6 +3908,7 @@ Path '', line 1, position 1.");
|
||||
|
||||
Assert.AreEqual(c.DateTimeOffsetValue, cISO.DateTimeOffsetValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void CircularConstructorDeserialize()
|
||||
@@ -8684,6 +8686,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual("derived", d.DerivedProperty);
|
||||
}
|
||||
|
||||
#if !(NET20 || NET35 || PORTABLE || PORTABLE40)
|
||||
[Test]
|
||||
public void DeserializeNullableUnsignedLong()
|
||||
{
|
||||
@@ -8705,6 +8708,7 @@ Path '', line 1, position 1.");
|
||||
set;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !NETFX_CORE
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user