-Removed Windows Phone from build
-Performance
This commit is contained in:
@@ -220,7 +220,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
byte[] data = HexToBytes("8C-00-00-00-12-30-00-FF-FF-FF-FF-FF-FF-FF-7F-12-31-00-FF-FF-FF-FF-FF-FF-FF-7F-10-32-00-FF-FF-FF-7F-10-33-00-FF-FF-FF-7F-10-34-00-FF-00-00-00-10-35-00-7F-00-00-00-02-36-00-02-00-00-00-61-00-01-37-00-00-00-00-00-00-00-F0-45-01-38-00-FF-FF-FF-FF-FF-FF-EF-7F-01-39-00-00-00-00-E0-FF-FF-EF-47-08-31-30-00-01-05-31-31-00-05-00-00-00-02-00-01-02-03-04-09-31-32-00-40-C5-E2-BA-E3-00-00-00-09-31-33-00-40-C5-E2-BA-E3-00-00-00-00");
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
reader.ReadRootValueAsArray = true;
|
||||
reader.DateTimeKindHandling = DateTimeKind.Utc;
|
||||
|
||||
@@ -429,7 +431,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
MemoryStream ms = new MemoryStream(data);
|
||||
BsonReader reader = new BsonReader(ms, true, DateTimeKind.Utc);
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
Assert.AreEqual(true, reader.ReadRootValueAsArray);
|
||||
Assert.AreEqual(DateTimeKind.Utc, reader.DateTimeKindHandling);
|
||||
@@ -566,7 +570,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
byte[] data = HexToBytes(hexdoc);
|
||||
|
||||
BsonReader reader = new BsonReader(new MemoryStream(data));
|
||||
#pragma warning disable 612,618
|
||||
reader.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
JObject o = (JObject)JToken.ReadFrom(reader);
|
||||
Assert.AreEqual(3, o.Count);
|
||||
@@ -587,7 +593,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
"82-00-00-00-07-5F-69-64-00-4A-78-93-79-17-22-00-00-00-00-61-CF-04-61-00-5D-00-00-00-01-30-00-00-00-00-00-00-00-F0-3F-01-31-00-00-00-00-00-00-00-00-40-01-32-00-00-00-00-00-00-00-08-40-01-33-00-00-00-00-00-00-00-10-40-01-34-00-00-00-00-00-00-00-14-50-01-35-00-00-00-00-00-00-00-18-40-01-36-00-00-00-00-00-00-00-1C-40-01-37-00-00-00-00-00-00-00-20-40-00-02-62-00-05-00-00-00-74-65-73-74-00-00");
|
||||
|
||||
BsonReader reader1 = new BsonReader(new MemoryStream(data1));
|
||||
#pragma warning disable 612,618
|
||||
reader1.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
// oid
|
||||
JObject o1 = (JObject)JToken.ReadFrom(reader1);
|
||||
@@ -596,7 +604,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
"87-00-00-00-05-5F-69-64-00-0C-00-00-00-02-4A-78-93-79-17-22-00-00-00-00-61-CF-04-61-00-5D-00-00-00-01-30-00-00-00-00-00-00-00-F0-3F-01-31-00-00-00-00-00-00-00-00-40-01-32-00-00-00-00-00-00-00-08-40-01-33-00-00-00-00-00-00-00-10-40-01-34-00-00-00-00-00-00-00-14-50-01-35-00-00-00-00-00-00-00-18-40-01-36-00-00-00-00-00-00-00-1C-40-01-37-00-00-00-00-00-00-00-20-40-00-02-62-00-05-00-00-00-74-65-73-74-00-00");
|
||||
|
||||
BsonReader reader2 = new BsonReader(new MemoryStream(data2));
|
||||
#pragma warning disable 612,618
|
||||
reader2.JsonNet35BinaryCompatibility = true;
|
||||
#pragma warning restore 612,618
|
||||
|
||||
// bytes
|
||||
JObject o2 = (JObject)JToken.ReadFrom(reader2);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -125,6 +125,8 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(@"{""NewMember"":""NewMember!"",""virtualMember"":""VirtualMember!"",""nonVirtualMember"":""NonVirtualMember!""}", result);
|
||||
}
|
||||
|
||||
// ignore hiding members compiler warning
|
||||
#pragma warning disable 108,114
|
||||
[DataContract]
|
||||
public class BaseWithContract
|
||||
{
|
||||
@@ -189,6 +191,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[DataMember(Name = "VirtualWithDataMemberSub")]
|
||||
public virtual string VirtualWithDataMember { get; set; }
|
||||
}
|
||||
#pragma warning restore 108,114
|
||||
|
||||
[Test]
|
||||
public void SubWithoutContractNewPropertiesTest()
|
||||
|
||||
Reference in New Issue
Block a user