Merge branch 'master' of https://github.com/JamesNK/Newtonsoft.Json
This commit is contained in:
+83
@@ -0,0 +1,83 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
[TestFixture]
|
||||
public class NamingStrategyAttributes : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
|
||||
public class User
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
[JsonProperty(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
|
||||
public int SnakeRating { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
User user = new User
|
||||
{
|
||||
FirstName = "Tom",
|
||||
LastName = "Riddle",
|
||||
SnakeRating = 10
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(user, Formatting.Indented);
|
||||
|
||||
Console.WriteLine(json);
|
||||
// {
|
||||
// "firstName": "Tom",
|
||||
// "lastName": "Riddle",
|
||||
// "snake_rating": 10
|
||||
// }
|
||||
#endregion
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""firstName"": ""Tom"",
|
||||
""lastName"": ""Riddle"",
|
||||
""snake_rating"": 10
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
[TestFixture]
|
||||
public class NamingStrategyCamelCase : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
public class User
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
User user1 = new User
|
||||
{
|
||||
UserName = "jamesn",
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new CamelCaseNamingStrategy()
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = contractResolver,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
// {
|
||||
// "userName": "jamesn",
|
||||
// "enabled": true
|
||||
// }
|
||||
#endregion
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""userName"": ""jamesn"",
|
||||
""enabled"": true
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
[TestFixture]
|
||||
public class NamingStrategySkipDictionaryKeys : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
public class DailyHighScores
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string Game { get; set; }
|
||||
public Dictionary<string, int> UserPoints { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
DailyHighScores dailyHighScores = new DailyHighScores
|
||||
{
|
||||
Date = new DateTime(2016, 6, 27, 0, 0, 0, DateTimeKind.Utc),
|
||||
Game = "Donkey Kong",
|
||||
UserPoints = new Dictionary<string, int>
|
||||
{
|
||||
["JamesNK"] = 9001,
|
||||
["JoC"] = 1337,
|
||||
["JessicN"] = 1000
|
||||
}
|
||||
};
|
||||
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new CamelCaseNamingStrategy
|
||||
{
|
||||
ProcessDictionaryKeys = false
|
||||
}
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(dailyHighScores, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = contractResolver,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
// {
|
||||
// "date": "2016-06-27T00:00:00Z",
|
||||
// "game": "Donkey Kong",
|
||||
// "userPoints": {
|
||||
// "JamesNK": 9001,
|
||||
// "JoC": 1337,
|
||||
// "JessicN": 1000
|
||||
// }
|
||||
// }
|
||||
#endregion
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""date"": ""2016-06-27T00:00:00Z"",
|
||||
""game"": ""Donkey Kong"",
|
||||
""userPoints"": {
|
||||
""JamesNK"": 9001,
|
||||
""JoC"": 1337,
|
||||
""JessicN"": 1000
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
[TestFixture]
|
||||
public class NamingStrategySkipSpecifiedNames : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
public class User
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
[JsonProperty(PropertyName = "UPN")]
|
||||
public string Upn { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
User user = new User
|
||||
{
|
||||
FirstName = "John",
|
||||
LastName = "Smith",
|
||||
Upn = "john.smith@acme.com"
|
||||
};
|
||||
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new CamelCaseNamingStrategy
|
||||
{
|
||||
OverrideSpecifiedNames = false
|
||||
}
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(user, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = contractResolver,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
// {
|
||||
// "firstName": "John",
|
||||
// "lastName": "Smith",
|
||||
// "UPN": "john.smith@acme.com"
|
||||
// }
|
||||
#endregion
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""firstName"": ""John"",
|
||||
""lastName"": ""Smith"",
|
||||
""UPN"": ""john.smith@acme.com""
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
[TestFixture]
|
||||
public class NamingStrategySnakeCase : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
public class User
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
User user1 = new User
|
||||
{
|
||||
UserName = "jamesn",
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new SnakeCaseNamingStrategy()
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = contractResolver,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
// {
|
||||
// "user_name": "jamesn",
|
||||
// "enabled": true
|
||||
// }
|
||||
#endregion
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""user_name"": ""jamesn"",
|
||||
""enabled"": true
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,10 @@
|
||||
</Compile>
|
||||
<Compile Include="Documentation\Samples\Serializer\DeserializeMetadataPropertyHandling.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\JsonConstructorAttribute.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\NamingStrategyAttributes.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\NamingStrategySkipSpecifiedNames.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\NamingStrategySkipDictionaryKeys.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\NamingStrategyCamelCase.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\SerializeDateFormatString.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\DeserializeCollection.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\DeserializeConstructorHandling.cs" />
|
||||
@@ -205,6 +209,7 @@
|
||||
<Compile Include="Documentation\Samples\Serializer\SerializeUnindentedJson.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\SerializeWithJsonConverters.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\SerializeWithJsonSerializerToFile.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\NamingStrategySnakeCase.cs" />
|
||||
<Compile Include="Documentation\Samples\Serializer\TraceWriter.cs" />
|
||||
<Compile Include="Documentation\Samples\Xml\ConvertJsonToXml.cs" />
|
||||
<Compile Include="Documentation\Samples\Xml\ConvertXmlToJson.cs" />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"Autofac": "4.0.0-beta7-130",
|
||||
"Autofac": "4.0.0-rc2-240",
|
||||
"FSharp.Core": "4.0.0.1",
|
||||
"NUnit": "2.6.2",
|
||||
"System.Buffers": "4.0.0-rc2-24027",
|
||||
"System.Buffers": "4.0.0",
|
||||
"System.Collections.Immutable": "1.1.37"
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -41,7 +41,9 @@ using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
@@ -1561,7 +1563,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
});
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests]], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<Event1[,]>), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""$values"": [
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests"",
|
||||
|
||||
@@ -7234,7 +7234,7 @@ Path '', line 1, position 1.");
|
||||
""Longitude"": -117.766684,
|
||||
""TimeStamp"": ""2000-03-01T23:59:59Z"",
|
||||
""Payload"": {
|
||||
""$type"": ""System.Byte[], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(byte[]), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""$value"": ""AAECAwQFBgcICQ==""
|
||||
}
|
||||
}", jsonString);
|
||||
|
||||
@@ -28,6 +28,7 @@ using System.Collections.Generic;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
@@ -133,7 +134,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string serializedString = JsonConvert.SerializeObject(inputContext, jsonSerializerSettings);
|
||||
|
||||
StringAssert.AreEqual(@"{
|
||||
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Guid, mscorlib]], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(Dictionary<string, Guid>), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""k1"": ""5dd2dba0-20c0-49f8-a054-1fa3b0a8d774""
|
||||
}", serializedString);
|
||||
|
||||
@@ -165,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
""Longitude"": -117.766684,
|
||||
""TimeStamp"": ""2000-03-01T23:59:59Z"",
|
||||
""Payload"": {
|
||||
""$type"": ""System.Byte[], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(byte[]), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""$value"": ""AAECAwQFBgcICQ==""
|
||||
}
|
||||
}", jsonString);
|
||||
|
||||
@@ -29,7 +29,9 @@ using System.IO;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
@@ -116,7 +118,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+Container, Newtonsoft.Json.Tests"",
|
||||
""ListA"": {
|
||||
""$id"": ""2"",
|
||||
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+ContentA, Newtonsoft.Json.Tests]], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<ContentA>), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""$values"": [
|
||||
{
|
||||
""$id"": ""3"",
|
||||
@@ -127,7 +129,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
},
|
||||
""ListB"": {
|
||||
""$id"": ""4"",
|
||||
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.Serialization.PreserveReferencesHandlingTests+ContentA, Newtonsoft.Json.Tests]], mscorlib"",
|
||||
""$type"": """ + ReflectionUtils.GetTypeName(typeof(List<ContentA>), 0, DefaultSerializationBinder.Instance) + @""",
|
||||
""$values"": [
|
||||
{
|
||||
""$ref"": ""3""
|
||||
|
||||
@@ -24,6 +24,7 @@ using NUnit.Framework;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NET20
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
@@ -551,12 +552,12 @@ Newtonsoft.Json Error: 0 : Error!
|
||||
});
|
||||
|
||||
Assert.AreEqual("Started serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[0].Message);
|
||||
Assert.AreEqual("Writing type name 'System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib' for System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[1].Message);
|
||||
Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(List<object>), 0, DefaultSerializationBinder.Instance) + "' for System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[1].Message);
|
||||
Assert.AreEqual("Started serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values'.", traceWriter.TraceRecords[2].Message);
|
||||
Assert.AreEqual("Writing type name 'System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.String, mscorlib]], mscorlib' for System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[3].Message);
|
||||
Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(Dictionary<string, string>), 0, DefaultSerializationBinder.Instance) + "' for System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[3].Message);
|
||||
Assert.AreEqual("Finished serializing System.Collections.Generic.Dictionary`2[System.String,System.String]. Path '$values[0]'.", traceWriter.TraceRecords[4].Message);
|
||||
Assert.AreEqual("Started serializing System.Version. Path '$values[0]'.", traceWriter.TraceRecords[5].Message);
|
||||
Assert.AreEqual("Writing type name 'System.Version, mscorlib' for System.Version. Path '$values[1]'.", traceWriter.TraceRecords[6].Message);
|
||||
Assert.AreEqual("Writing type name '" + ReflectionUtils.GetTypeName(typeof(Version), 0, DefaultSerializationBinder.Instance) + "' for System.Version. Path '$values[1]'.", traceWriter.TraceRecords[6].Message);
|
||||
Assert.AreEqual("Finished serializing System.Version. Path '$values[1]'.", traceWriter.TraceRecords[7].Message);
|
||||
Assert.AreEqual("Finished serializing System.Collections.Generic.List`1[System.Object]. Path ''.", traceWriter.TraceRecords[8].Message);
|
||||
}
|
||||
|
||||
@@ -298,12 +298,12 @@ namespace Newtonsoft.Json.Tests
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public static class Console
|
||||
{
|
||||
public static void WriteLine(params object[] args)
|
||||
public static class Console
|
||||
{
|
||||
public static void WriteLine(params object[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static class CustomAssert
|
||||
|
||||
@@ -89,14 +89,14 @@
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0-rc2-3002702"
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
|
||||
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
|
||||
"System.Runtime.Serialization.Json": "4.0.2-rc2-24027",
|
||||
"System.Runtime.Serialization.Xml": "4.1.1-rc2-24027",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1",
|
||||
"System.Xml.XmlSerializer": "4.0.11",
|
||||
"System.Runtime.Serialization.Json": "4.0.2",
|
||||
"System.Runtime.Serialization.Xml": "4.1.1",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-rc2-build10015"
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029"
|
||||
},
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
|
||||
@@ -106,28 +106,28 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.CSharp": "4.0.1-rc2-24027",
|
||||
"System.Collections": "4.0.11-rc2-24027",
|
||||
"System.Diagnostics.Debug": "4.0.11-rc2-24027",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
|
||||
"System.Globalization": "4.0.11-rc2-24027",
|
||||
"System.IO": "4.1.0-rc2-24027",
|
||||
"System.Linq": "4.1.0-rc2-24027",
|
||||
"System.Linq.Expressions": "4.0.11-rc2-24027",
|
||||
"System.ObjectModel": "4.0.12-rc2-24027",
|
||||
"System.Reflection": "4.1.0-rc2-24027",
|
||||
"System.Reflection.Extensions": "4.0.1-rc2-24027",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-24027",
|
||||
"System.Runtime": "4.1.0-rc2-24027",
|
||||
"System.Runtime.Extensions": "4.1.0-rc2-24027",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
|
||||
"System.Text.Encoding": "4.0.11-rc2-24027",
|
||||
"System.Text.Encoding.Extensions": "4.0.11-rc2-24027",
|
||||
"System.Text.RegularExpressions": "4.0.12-rc2-24027",
|
||||
"System.Threading": "4.0.11-rc2-24027",
|
||||
"System.Threading.Tasks": "4.0.11-rc2-24027",
|
||||
"System.Xml.ReaderWriter": "4.0.11-rc2-24027",
|
||||
"System.Xml.XDocument": "4.0.11-rc2-24027"
|
||||
"Microsoft.CSharp": "4.0.1",
|
||||
"System.Collections": "4.0.11",
|
||||
"System.Diagnostics.Debug": "4.0.11",
|
||||
"System.Dynamic.Runtime": "4.0.11",
|
||||
"System.Globalization": "4.0.11",
|
||||
"System.IO": "4.1.0",
|
||||
"System.Linq": "4.1.0",
|
||||
"System.Linq.Expressions": "4.1.0",
|
||||
"System.ObjectModel": "4.0.12",
|
||||
"System.Reflection": "4.1.0",
|
||||
"System.Reflection.Extensions": "4.0.1",
|
||||
"System.Resources.ResourceManager": "4.0.1",
|
||||
"System.Runtime": "4.1.0",
|
||||
"System.Runtime.Extensions": "4.1.0",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1",
|
||||
"System.Text.Encoding": "4.0.11",
|
||||
"System.Text.Encoding.Extensions": "4.0.11",
|
||||
"System.Text.RegularExpressions": "4.1.0",
|
||||
"System.Threading": "4.0.11",
|
||||
"System.Threading.Tasks": "4.0.11",
|
||||
"System.Xml.ReaderWriter": "4.0.11",
|
||||
"System.Xml.XDocument": "4.0.11"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<!--<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />-->
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<!--<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />-->
|
||||
<add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user