-Removed Windows Phone from build
-Performance
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
#if !NETFX_CORE
|
||||
using NUnit.Framework;
|
||||
@@ -67,6 +68,14 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
public class EscapedPropertiesContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected internal override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
return base.ResolvePropertyName(propertyName + @"-'-""-");
|
||||
}
|
||||
}
|
||||
|
||||
public class Book
|
||||
{
|
||||
public string BookName { get; set; }
|
||||
@@ -99,6 +108,28 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[TestFixture]
|
||||
public class ContractResolverTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void SerializeWithEscapedPropertyName()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(
|
||||
new AddressWithDataMember
|
||||
{
|
||||
AddressLine1 = "value!"
|
||||
},
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new EscapedPropertiesContractResolver()
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{""AddressLine1-'-\""-"":""value!""}", json);
|
||||
|
||||
JsonTextReader reader = new JsonTextReader(new StringReader(json));
|
||||
reader.Read();
|
||||
reader.Read();
|
||||
|
||||
Assert.AreEqual(@"AddressLine1-'-""-", reader.Value);
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
[Test]
|
||||
public void DeserializeDataMemberClassWithNoDataContract()
|
||||
|
||||
Reference in New Issue
Block a user