-Fixed unclosed object when including type name with array
This commit is contained in:
@@ -91,6 +91,7 @@
|
||||
<Compile Include="TestObjects\ClassAndMemberConverterClass.cs" />
|
||||
<Compile Include="TestObjects\ClassConverterPrecedenceClassConverter.cs" />
|
||||
<Compile Include="TestObjects\ConstructorCaseSensitivityClass.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
<Compile Include="TestObjects\ConverterPrecedenceClass.cs" />
|
||||
<Compile Include="TestObjects\ConverterPrecedenceClassConverter.cs" />
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<Compile Include="Linq\ComponentModel\JTypeDescriptorTests.cs" />
|
||||
<Compile Include="Linq\JPathTests.cs" />
|
||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
<Compile Include="TestObjects\DictionaryInterfaceClass.cs" />
|
||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
<Compile Include="TestObjects\ClassAndMemberConverterClass.cs" />
|
||||
<Compile Include="TestObjects\ClassConverterPrecedenceClassConverter.cs" />
|
||||
<Compile Include="TestObjects\ConstructorCaseSensitivityClass.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
<Compile Include="TestObjects\ConverterPrecedenceClass.cs" />
|
||||
<Compile Include="TestObjects\ConverterPrecedenceClassConverter.cs" />
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
|
||||
@@ -280,10 +280,42 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
Assert.IsInstanceOfType(typeof(SendHttpRequest), message);
|
||||
|
||||
SendHttpRequest request = (SendHttpRequest) message;
|
||||
SendHttpRequest request = (SendHttpRequest)message;
|
||||
Assert.AreEqual("xyz", request.CorrelationId);
|
||||
Assert.AreEqual(2, request.RequestData.Count);
|
||||
Assert.AreEqual("siedemnaście", request.RequestData["Id"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeObjectWithMultipleGenericLists()
|
||||
{
|
||||
string containerTypeName = typeof(Container).AssemblyQualifiedName;
|
||||
string productTypeName = typeof(Product).AssemblyQualifiedName;
|
||||
|
||||
Container container = new Container
|
||||
{
|
||||
In = new List<Product>(),
|
||||
Out = new List<Product>()
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(container, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
TypeNameHandling = TypeNameHandling.All
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""$type"": """ + containerTypeName + @""",
|
||||
""In"": {
|
||||
""$type"": ""System.Collections.Generic.List`1[[" + productTypeName + @"]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"",
|
||||
""$values"": []
|
||||
},
|
||||
""Out"": {
|
||||
""$type"": ""System.Collections.Generic.List`1[[" + productTypeName + @"]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"",
|
||||
""$values"": []
|
||||
}
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class Container
|
||||
{
|
||||
public IList<Product> In { get; set; }
|
||||
public IList<Product> Out { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
|
||||
writer.WriteEndArray();
|
||||
|
||||
if (isReference)
|
||||
if (isReference || includeTypeDetails)
|
||||
{
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user