Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamesNK <james@newtonking.com>2010-12-19 03:29:41 +0300
committerJamesNK <james@newtonking.com>2010-12-19 03:29:41 +0300
commit5ccd8269515c0943d51cfd79e32e31b6a82b3c48 (patch)
treeedcff2207d13aa3aac09c95407ff1e9fcca1e1b8
parent2e7b8e5279722460eca81abb26fb58539d2d70d6 (diff)
-Change BSON writer to write new binary subtype
-Fix BSON reader to read the old binary subtype correctly -Added JsonNet35BinaryCompadibility to BSON reader for incorrectly written BSON binary values -Changed JSON schema to use required flags instead of optional as defined in JSON schema spec 3.0 -Changed JSON schema to use divisibleBy instead of maxDecimals as defined in JSON schema spec 3.0 -Fixed detection of serialization specified flag properties -Updated to latest version of NuGet
-rw-r--r--Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs7
-rw-r--r--Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs15
-rw-r--r--Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs28
-rw-r--r--Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs4
-rw-r--r--Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs14
-rw-r--r--Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs38
-rw-r--r--Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs12
-rw-r--r--Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs59
-rw-r--r--Src/Newtonsoft.Json/Bson/BsonBinaryType.cs4
-rw-r--r--Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs2
-rw-r--r--Src/Newtonsoft.Json/Bson/BsonReader.cs24
-rw-r--r--Src/Newtonsoft.Json/JsonValidatingReader.cs15
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchema.cs6
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs8
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchemaConstants.cs4
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs12
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchemaModel.cs14
-rw-r--r--Src/Newtonsoft.Json/Schema/JsonSchemaWriter.cs4
-rw-r--r--Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs4
-rw-r--r--Tools/NuGet/NuGet.exebin192512 -> 267264 bytes
20 files changed, 194 insertions, 80 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
index 3d28163..7b2cf1b 100644
--- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs
@@ -72,6 +72,7 @@ namespace Newtonsoft.Json.Tests.Bson
byte[] data = MiscellaneousUtils.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);
+ reader.JsonNet35BinaryCompadibility = true;
reader.ReadRootValueAsArray = true;
reader.DateTimeKindHandling = DateTimeKind.Utc;
@@ -250,6 +251,7 @@ namespace Newtonsoft.Json.Tests.Bson
MemoryStream ms = new MemoryStream(data);
BsonReader reader = new BsonReader(ms, true, DateTimeKind.Utc);
+ reader.JsonNet35BinaryCompadibility = true;
Assert.AreEqual(true, reader.ReadRootValueAsArray);
Assert.AreEqual(DateTimeKind.Utc, reader.DateTimeKindHandling);
@@ -378,11 +380,12 @@ namespace Newtonsoft.Json.Tests.Bson
[Test]
public void ReadNestedArrayIntoLinq()
{
- string hexdoc = "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";
+ string hexdoc = "87-00-00-00-05-5F-69-64-00-0C-00-00-00-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";
byte[] data = MiscellaneousUtils.HexToBytes(hexdoc);
BsonReader reader = new BsonReader(new MemoryStream(data));
+ reader.JsonNet35BinaryCompadibility = true;
JObject o = (JObject)JToken.ReadFrom(reader);
Assert.AreEqual(3, o.Count);
@@ -403,6 +406,7 @@ 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));
+ reader1.JsonNet35BinaryCompadibility = true;
// oid
JObject o1 = (JObject)JToken.ReadFrom(reader1);
@@ -411,6 +415,7 @@ 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));
+ reader2.JsonNet35BinaryCompadibility = true;
// bytes
JObject o2 = (JObject)JToken.ReadFrom(reader2);
diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs
index b90e74a..d8e38ca 100644
--- a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs
@@ -78,7 +78,7 @@ namespace Newtonsoft.Json.Tests.Bson
writer.WriteEnd();
string bson = MiscellaneousUtils.BytesToHex(ms.ToArray());
- Assert.AreEqual("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", bson);
+ Assert.AreEqual("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-00-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", bson);
}
#endif
@@ -120,10 +120,19 @@ namespace Newtonsoft.Json.Tests.Bson
ms.Seek(0, SeekOrigin.Begin);
- string expected = "2B-00-00-00-02-30-00-02-00-00-00-61-00-02-31-00-02-00-00-00-62-00-05-32-00-0C-00-00-00-02-48-65-6C-6C-6F-20-77-6F-72-6C-64-21-00";
+ string expected = "2B-00-00-00-02-30-00-02-00-00-00-61-00-02-31-00-02-00-00-00-62-00-05-32-00-0C-00-00-00-00-48-65-6C-6C-6F-20-77-6F-72-6C-64-21-00";
string bson = MiscellaneousUtils.BytesToHex(ms.ToArray());
Assert.AreEqual(expected, bson);
+
+ BsonReader reader = new BsonReader(new MemoryStream(ms.ToArray()));
+ reader.ReadRootValueAsArray = true;
+ reader.Read();
+ reader.Read();
+ reader.Read();
+ reader.Read();
+ Assert.AreEqual(JsonToken.Bytes, reader.TokenType);
+ Assert.AreEqual(data, reader.Value);
}
[Test]
@@ -157,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Bson
ms.Seek(0, SeekOrigin.Begin);
- string expected = "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";
+ string expected = "87-00-00-00-05-5F-69-64-00-0C-00-00-00-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";
string bson = MiscellaneousUtils.BytesToHex(ms.ToArray());
Assert.AreEqual(expected, bson);
diff --git a/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs b/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs
index 2c12ca4..26d7eff 100644
--- a/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs
+++ b/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs
@@ -470,7 +470,7 @@ namespace Newtonsoft.Json.Tests
""type"":""array"",
""items"":{
""type"":""number"",
- ""maxDecimal"":2
+ ""divisibleBy"":0.1
}
}";
@@ -494,7 +494,7 @@ namespace Newtonsoft.Json.Tests
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.Float, reader.TokenType);
- Assert.AreEqual(@"Float 4.001 exceeds the maximum allowed number decimal places of 2. Line 1, position 15.", validationEventArgs.Message);
+ Assert.AreEqual(@"Float 4.001 is not evenly divisible by 0.1. Line 1, position 15.", validationEventArgs.Message);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);
@@ -700,7 +700,7 @@ namespace Newtonsoft.Json.Tests
}
[Test]
- public void MissingNonoptionalProperties()
+ public void MissingRequiredProperties()
{
string schemaJson = @"{
""description"":""A person"",
@@ -708,8 +708,8 @@ namespace Newtonsoft.Json.Tests
""properties"":
{
""name"":{""type"":""string""},
- ""hobbies"":{""type"":""string""},
- ""age"":{""type"":""integer""}
+ ""hobbies"":{""type"":""string"",""required"":true},
+ ""age"":{""type"":""integer"",""required"":true}
}
}";
@@ -735,22 +735,22 @@ namespace Newtonsoft.Json.Tests
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
- Assert.AreEqual("Non-optional properties are missing from object: hobbies, age. Line 1, position 16.", validationEventArgs.Message);
+ Assert.AreEqual("Required properties are missing from object: hobbies, age. Line 1, position 16.", validationEventArgs.Message);
Assert.IsNotNull(validationEventArgs);
}
[Test]
- public void MissingOptionalProperties()
+ public void MissingNonRequiredProperties()
{
string schemaJson = @"{
""description"":""A person"",
""type"":""object"",
""properties"":
{
- ""name"":{""type"":""string""},
- ""hobbies"":{""type"":""string"",optional:true},
- ""age"":{""type"":""integer"",optional:true}
+ ""name"":{""type"":""string"",""required"":true},
+ ""hobbies"":{""type"":""string"",""required"":false},
+ ""age"":{""type"":""integer""}
}
}";
@@ -873,7 +873,7 @@ namespace Newtonsoft.Json.Tests
""type"":""object"",
""properties"":
{
- ""firstproperty"":{""type"":""string""}
+ ""firstproperty"":{""type"":""string"",""required"":true}
},
""additionalProperties"":{}
}";
@@ -884,7 +884,7 @@ namespace Newtonsoft.Json.Tests
""extends"":{""$ref"":""first""},
""properties"":
{
- ""secondproperty"":{""type"":""string""}
+ ""secondproperty"":{""type"":""string"",""required"":true}
},
""additionalProperties"":false
}";
@@ -955,7 +955,7 @@ namespace Newtonsoft.Json.Tests
}
[Test]
- public void ExtendsMissingNonoptionalProperties()
+ public void ExtendsMissingRequiredProperties()
{
string json = "{}";
@@ -972,7 +972,7 @@ namespace Newtonsoft.Json.Tests
Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
Assert.AreEqual(1, errors.Count);
- Assert.AreEqual("Non-optional properties are missing from object: secondproperty, firstproperty. Line 1, position 2.", errors[0]);
+ Assert.AreEqual("Required properties are missing from object: secondproperty, firstproperty. Line 1, position 2.", errors[0]);
}
[Test]
diff --git a/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs b/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs
index 92e52e7..31ed7d9 100644
--- a/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs
@@ -89,13 +89,13 @@ namespace Newtonsoft.Json.Tests.Schema
[Test]
public void ValidateFailureWithOutLineInfoBecauseOfEndToken()
{
- JsonSchema schema = JsonSchema.Parse("{'properties':{'lol':{}}}");
+ JsonSchema schema = JsonSchema.Parse("{'properties':{'lol':{'required':true}}}");
JObject o = JObject.Parse("{}");
List<string> errors = new List<string>();
o.Validate(schema, (sender, args) => errors.Add(args.Message));
- Assert.AreEqual("Non-optional properties are missing from object: lol.", errors[0]);
+ Assert.AreEqual("Required properties are missing from object: lol.", errors[0]);
Assert.AreEqual(1, errors.Count);
}
diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs
index ee108e6..b3bba9b 100644
--- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs
@@ -116,18 +116,18 @@ namespace Newtonsoft.Json.Tests.Schema
}
[Test]
- public void Optional()
+ public void Required()
{
string json = @"{
- ""description"":""Optional"",
- ""optional"":true
+ ""description"":""Required"",
+ ""required"":true
}";
JsonSchemaBuilder builder = new JsonSchemaBuilder(new JsonSchemaResolver());
JsonSchema schema = builder.Parse(new JsonTextReader(new StringReader(json)));
- Assert.AreEqual("Optional", schema.Description);
- Assert.AreEqual(true, schema.Optional);
+ Assert.AreEqual("Required", schema.Description);
+ Assert.AreEqual(true, schema.Required);
}
[Test]
@@ -279,7 +279,7 @@ namespace Newtonsoft.Json.Tests.Schema
""maxItems"":2,
""minLength"":5,
""maxLength"":50,
- ""maxDecimal"":3,
+ ""divisibleBy"":3,
}";
JsonSchemaBuilder builder = new JsonSchemaBuilder(new JsonSchemaResolver());
@@ -292,7 +292,7 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(2, schema.MaximumItems);
Assert.AreEqual(5, schema.MinimumLength);
Assert.AreEqual(50, schema.MaximumLength);
- Assert.AreEqual(3, schema.MaximumDecimals);
+ Assert.AreEqual(3, schema.DivisibleBy);
}
[Test]
diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs
index eb48444..ed8a6d4 100644
--- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs
@@ -94,10 +94,12 @@ namespace Newtonsoft.Json.Tests.Schema
""additionalProperties"": false,
""properties"": {
""TestField1"": {
+ ""required"": true,
""type"": ""integer"",
""default"": 21
},
""TestProperty1"": {
+ ""required"": true,
""type"": [
""string"",
""null""
@@ -124,15 +126,18 @@ namespace Newtonsoft.Json.Tests.Schema
""type"": ""object"",
""properties"": {
""Name"": {
+ ""required"": true,
""type"": [
""string"",
""null""
]
},
""BirthDate"": {
+ ""required"": true,
""type"": ""string""
},
""LastModified"": {
+ ""required"": true,
""type"": ""string""
}
}
@@ -151,36 +156,43 @@ namespace Newtonsoft.Json.Tests.Schema
""type"": ""object"",
""properties"": {
""Id"": {
+ ""required"": true,
""type"": ""string""
},
""FName"": {
+ ""required"": true,
""type"": [
""string"",
""null""
]
},
""LName"": {
+ ""required"": true,
""type"": [
""string"",
""null""
]
},
""RoleId"": {
+ ""required"": true,
""type"": ""integer""
},
""NullableRoleId"": {
+ ""required"": true,
""type"": [
""integer"",
""null""
]
},
""NullRoleId"": {
+ ""required"": true,
""type"": [
""integer"",
""null""
]
},
""Active"": {
+ ""required"": true,
""type"": [
""boolean"",
""null""
@@ -370,6 +382,7 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(@"{
""id"": ""System.IO.DirectoryInfo"",
+ ""required"": true,
""type"": [
""object"",
""null""
@@ -377,6 +390,7 @@ namespace Newtonsoft.Json.Tests.Schema
""additionalProperties"": false,
""properties"": {
""Name"": {
+ ""required"": true,
""type"": [
""string"",
""null""
@@ -386,39 +400,49 @@ namespace Newtonsoft.Json.Tests.Schema
""$ref"": ""System.IO.DirectoryInfo""
},
""Exists"": {
+ ""required"": true,
""type"": ""boolean""
},
""FullName"": {
+ ""required"": true,
""type"": [
""string"",
""null""
]
},
""Extension"": {
+ ""required"": true,
""type"": [
""string"",
""null""
]
},
""CreationTime"": {
+ ""required"": true,
""type"": ""string""
},
""CreationTimeUtc"": {
+ ""required"": true,
""type"": ""string""
},
""LastAccessTime"": {
+ ""required"": true,
""type"": ""string""
},
""LastAccessTimeUtc"": {
+ ""required"": true,
""type"": ""string""
},
""LastWriteTime"": {
+ ""required"": true,
""type"": ""string""
},
""LastWriteTimeUtc"": {
+ ""required"": true,
""type"": ""string""
},
""Attributes"": {
+ ""required"": true,
""type"": ""integer""
}
}
@@ -458,21 +482,27 @@ namespace Newtonsoft.Json.Tests.Schema
""additionalProperties"": false,
""properties"": {
""major"": {
+ ""required"": true,
""type"": ""integer""
},
""minor"": {
+ ""required"": true,
""type"": ""integer""
},
""build"": {
+ ""required"": true,
""type"": ""integer""
},
""revision"": {
+ ""required"": true,
""type"": ""integer""
},
""majorRevision"": {
+ ""required"": true,
""type"": ""integer""
},
""minorRevision"": {
+ ""required"": true,
""type"": ""integer""
}
}
@@ -503,6 +533,7 @@ namespace Newtonsoft.Json.Tests.Schema
""type"": ""object"",
""properties"": {
""x"": {
+ ""required"": true,
""type"": ""integer"",
""enum"": [
0,
@@ -552,13 +583,13 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(@"{
""id"": ""Newtonsoft.Json.Tests.TestObjects.CircularReferenceClass"",
- ""optional"": true,
""type"": [
""object"",
""null""
],
""properties"": {
""Name"": {
+ ""required"": true,
""type"": ""string""
},
""Child"": {
@@ -579,13 +610,13 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(@"{
""id"": ""Newtonsoft.Json.Tests.TestObjects.JsonPropertyWithHandlingValues"",
+ ""required"": true,
""type"": [
""object"",
""null""
],
""properties"": {
""DefaultValueHandlingIgnoreProperty"": {
- ""optional"": true,
""type"": [
""string"",
""null""
@@ -593,6 +624,7 @@ namespace Newtonsoft.Json.Tests.Schema
""default"": ""Default!""
},
""DefaultValueHandlingIncludeProperty"": {
+ ""required"": true,
""type"": [
""string"",
""null""
@@ -600,13 +632,13 @@ namespace Newtonsoft.Json.Tests.Schema
""default"": ""Default!""
},
""NullValueHandlingIgnoreProperty"": {
- ""optional"": true,
""type"": [
""string"",
""null""
]
},
""NullValueHandlingIncludeProperty"": {
+ ""required"": true,
""type"": [
""string"",
""null""
diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs
index 220047e..ae2e01a 100644
--- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs
@@ -139,7 +139,7 @@ namespace Newtonsoft.Json.Tests.Schema
}
[Test]
- public void Optional()
+ public void Required()
{
string schemaJson = @"{
""description"":""A person"",
@@ -147,8 +147,8 @@ namespace Newtonsoft.Json.Tests.Schema
""properties"":
{
""name"":{""type"":""string""},
- ""hobbies"":{""type"":""string"",optional:true},
- ""age"":{""type"":""integer"",optional:true}
+ ""hobbies"":{""type"":""string"",required:true},
+ ""age"":{""type"":""integer"",required:true}
}
}";
@@ -158,9 +158,9 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(JsonSchemaType.Object, model.Type);
Assert.AreEqual(3, model.Properties.Count);
- Assert.AreEqual(false, model.Properties["name"].Optional);
- Assert.AreEqual(true, model.Properties["hobbies"].Optional);
- Assert.AreEqual(true, model.Properties["age"].Optional);
+ Assert.AreEqual(false, model.Properties["name"].Required);
+ Assert.AreEqual(true, model.Properties["hobbies"].Required);
+ Assert.AreEqual(true, model.Properties["age"].Required);
}
}
} \ No newline at end of file
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
index d9026ce..0aa91a7 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
@@ -3385,6 +3385,7 @@ keyword such as type of business.""
public string Name { get; set; }
public int Age { get; set; }
public int Weight { get; set; }
+ public int Height { get; set; }
// dummy. should never be used because it isn't of type bool
[JsonIgnore]
@@ -3399,6 +3400,10 @@ keyword such as type of business.""
[JsonIgnore]
public bool WeightSpecified;
+
+ [JsonIgnore]
+ [System.Xml.Serialization.XmlIgnoreAttribute]
+ public bool HeightSpecified;
}
[Test]
@@ -3419,28 +3424,36 @@ keyword such as type of business.""
Assert.IsNull(deserialized.Name);
Assert.IsFalse(deserialized.NameSpecified);
Assert.IsFalse(deserialized.WeightSpecified);
+ Assert.IsFalse(deserialized.HeightSpecified);
Assert.AreEqual(27, deserialized.Age);
c.NameSpecified = true;
c.WeightSpecified = true;
+ c.HeightSpecified = true;
json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
""Name"": ""James"",
""Age"": 27,
- ""Weight"": 0
+ ""Weight"": 0,
+ ""Height"": 0
}", json);
deserialized = JsonConvert.DeserializeObject<SpecifiedTestClass>(json);
Assert.AreEqual("James", deserialized.Name);
Assert.IsTrue(deserialized.NameSpecified);
Assert.IsTrue(deserialized.WeightSpecified);
+ Assert.IsTrue(deserialized.HeightSpecified);
Assert.AreEqual(27, deserialized.Age);
+ }
+// [Test]
+// public void XmlSerializerSpecifiedTrueTest()
+// {
// XmlSerializer s = new XmlSerializer(typeof(OptionalOrder));
// StringWriter sw = new StringWriter();
-// s.Serialize(sw, new OptionalOrder() { FirstOrder = "First", FirstOrderSpecified = true});
+// s.Serialize(sw, new OptionalOrder() { FirstOrder = "First", FirstOrderSpecified = true });
// Console.WriteLine(sw.ToString());
@@ -3452,18 +3465,38 @@ keyword such as type of business.""
// OptionalOrder o = (OptionalOrder)s.Deserialize(new StringReader(xml));
// Console.WriteLine(o.FirstOrder);
// Console.WriteLine(o.FirstOrderSpecified);
- }
+// }
- //public class OptionalOrder
- //{
- // // This field shouldn't be serialized
- // // if it is uninitialized.
- // public string FirstOrder;
- // // Use the XmlIgnoreAttribute to ignore the
- // // special field named "FirstOrderSpecified".
- // [System.Xml.Serialization.XmlIgnoreAttribute]
- // public bool FirstOrderSpecified;
- //}
+// [Test]
+// public void XmlSerializerSpecifiedFalseTest()
+// {
+// XmlSerializer s = new XmlSerializer(typeof(OptionalOrder));
+
+// StringWriter sw = new StringWriter();
+// s.Serialize(sw, new OptionalOrder() { FirstOrder = "First", FirstOrderSpecified = false });
+
+// Console.WriteLine(sw.ToString());
+
+//// string xml = @"<?xml version=""1.0"" encoding=""utf-16""?>
+////<OptionalOrder xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
+//// <FirstOrder>First</FirstOrder>
+////</OptionalOrder>";
+
+//// OptionalOrder o = (OptionalOrder)s.Deserialize(new StringReader(xml));
+//// Console.WriteLine(o.FirstOrder);
+//// Console.WriteLine(o.FirstOrderSpecified);
+// }
+
+ public class OptionalOrder
+ {
+ // This field shouldn't be serialized
+ // if it is uninitialized.
+ public string FirstOrder;
+ // Use the XmlIgnoreAttribute to ignore the
+ // special field named "FirstOrderSpecified".
+ [System.Xml.Serialization.XmlIgnoreAttribute]
+ public bool FirstOrderSpecified;
+ }
public class FamilyDetails
{
diff --git a/Src/Newtonsoft.Json/Bson/BsonBinaryType.cs b/Src/Newtonsoft.Json/Bson/BsonBinaryType.cs
index 2c4f7df..1db3166 100644
--- a/Src/Newtonsoft.Json/Bson/BsonBinaryType.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonBinaryType.cs
@@ -23,11 +23,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
+using System;
+
namespace Newtonsoft.Json.Bson
{
internal enum BsonBinaryType : byte
{
+ Binary = 0x00,
Function = 0x01,
+ [Obsolete("This type has been deprecated in the BSON specification. Use Binary instead.")]
Data = 0x02,
Uuid = 0x03,
Md5 = 0x05,
diff --git a/Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs b/Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs
index 84a7ffb..7c0d476 100644
--- a/Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Bson
byte[] data = (byte[])value.Value;
_writer.Write(data.Length);
- _writer.Write((byte)BsonBinaryType.Data);
+ _writer.Write((byte)BsonBinaryType.Binary);
_writer.Write(data);
}
break;
diff --git a/Src/Newtonsoft.Json/Bson/BsonReader.cs b/Src/Newtonsoft.Json/Bson/BsonReader.cs
index 2628cfe..0401984 100644
--- a/Src/Newtonsoft.Json/Bson/BsonReader.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonReader.cs
@@ -55,6 +55,7 @@ namespace Newtonsoft.Json.Bson
private ContainerContext _currentContext;
private bool _readRootValueAsArray;
+ private bool _jsonNet35BinaryCompadibility;
private DateTimeKind _dateTimeKindHandling;
private enum BsonReaderState
@@ -83,6 +84,18 @@ namespace Newtonsoft.Json.Bson
}
/// <summary>
+ /// Gets or sets a value indicating whether binary data reading should compatible with incorrect Json.NET 3.5 written binary.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if binary data reading will be compatible with incorrect Json.NET 3.5 written binary; otherwise, <c>false</c>.
+ /// </value>
+ public bool JsonNet35BinaryCompadibility
+ {
+ get { return _jsonNet35BinaryCompadibility; }
+ set { _jsonNet35BinaryCompadibility = value; }
+ }
+
+ /// <summary>
/// Gets or sets a value indicating whether the root object will be read as a JSON array.
/// </summary>
/// <value>
@@ -526,8 +539,15 @@ namespace Newtonsoft.Json.Bson
{
int dataLength = ReadInt32();
- // BsonBinaryType not used
- ReadByte();
+ BsonBinaryType binaryType = (BsonBinaryType)ReadByte();
+
+#pragma warning disable 612,618
+ // the old binary type has the data length repeated in the data for some reason
+ if (binaryType == BsonBinaryType.Data && !_jsonNet35BinaryCompadibility)
+ {
+ dataLength = ReadInt32();
+ }
+#pragma warning restore 612,618
return ReadBytes(dataLength);
}
diff --git a/Src/Newtonsoft.Json/JsonValidatingReader.cs b/Src/Newtonsoft.Json/JsonValidatingReader.cs
index fd351c9..6fc83ce 100644
--- a/Src/Newtonsoft.Json/JsonValidatingReader.cs
+++ b/Src/Newtonsoft.Json/JsonValidatingReader.cs
@@ -77,7 +77,7 @@ namespace Newtonsoft.Json
private IEnumerable<string> GetRequiredProperties(JsonSchemaModel schema)
{
- return schema.Properties.Where(p => !p.Value.Optional).Select(p => p.Key);
+ return schema.Properties.Where(p => p.Value.Required).Select(p => p.Key);
}
}
@@ -448,7 +448,7 @@ namespace Newtonsoft.Json
requiredProperties.Where(kv => !kv.Value).Select(kv => kv.Key).ToList();
if (unmatchedRequiredProperties.Count > 0)
- RaiseError("Non-optional properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), schema);
+ RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), schema);
}
}
@@ -564,8 +564,15 @@ namespace Newtonsoft.Json
if (schema.Minimum != null && value < schema.Minimum)
RaiseError("Float {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), schema);
- if (schema.MaximumDecimals != null && MathUtils.GetDecimalPlaces(value) > schema.MaximumDecimals)
- RaiseError("Float {0} exceeds the maximum allowed number decimal places of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MaximumDecimals), schema);
+ if (schema.DivisibleBy != null && !IsZero(value % schema.DivisibleBy.Value))
+ RaiseError("Float {0} is not evenly divisible by {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.DivisibleBy), schema);
+ }
+
+ private static bool IsZero(double value)
+ {
+ double epsilon = 2.2204460492503131e-016;
+
+ return Math.Abs(value) < 10.0 * epsilon;
}
private void ValidatePropertyName(JsonSchemaModel schema)
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchema.cs b/Src/Newtonsoft.Json/Schema/JsonSchema.cs
index eef40c2..c5c752f 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchema.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchema.cs
@@ -49,9 +49,9 @@ namespace Newtonsoft.Json.Schema
/// </summary>
public string Title { get; set; }
/// <summary>
- /// Gets or sets whether the object is optional.
+ /// Gets or sets whether the object is required.
/// </summary>
- public bool? Optional { get; set; }
+ public bool? Required { get; set; }
/// <summary>
/// Gets or sets whether the object is read only.
/// </summary>
@@ -92,7 +92,7 @@ namespace Newtonsoft.Json.Schema
/// Gets or sets the maximum decimals.
/// </summary>
/// <value>The maximum decimals.</value>
- public int? MaximumDecimals { get; set; }
+ public double? DivisibleBy { get; set; }
/// <summary>
/// Gets or sets the minimum.
/// </summary>
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs
index 399ff4c..e5e5ad4 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs
@@ -146,8 +146,8 @@ namespace Newtonsoft.Json.Schema
case JsonSchemaConstants.AdditionalPropertiesPropertyName:
ProcessAdditionalProperties();
break;
- case JsonSchemaConstants.OptionalPropertyName:
- CurrentSchema.Optional = (bool)_reader.Value;
+ case JsonSchemaConstants.RequiredPropertyName:
+ CurrentSchema.Required = (bool)_reader.Value;
break;
case JsonSchemaConstants.RequiresPropertyName:
CurrentSchema.Requires = (string) _reader.Value;
@@ -173,8 +173,8 @@ namespace Newtonsoft.Json.Schema
case JsonSchemaConstants.MinimumItemsPropertyName:
CurrentSchema.MinimumItems = Convert.ToInt32(_reader.Value, CultureInfo.InvariantCulture);
break;
- case JsonSchemaConstants.MaximumDecimalsPropertyName:
- CurrentSchema.MaximumDecimals = Convert.ToInt32(_reader.Value, CultureInfo.InvariantCulture);
+ case JsonSchemaConstants.DivisibleByPropertyName:
+ CurrentSchema.DivisibleBy = Convert.ToDouble(_reader.Value, CultureInfo.InvariantCulture);
break;
case JsonSchemaConstants.DisallowPropertyName:
CurrentSchema.Disallow = ProcessType();
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaConstants.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaConstants.cs
index 2b31fba..906b45f 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaConstants.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaConstants.cs
@@ -35,7 +35,7 @@ namespace Newtonsoft.Json.Schema
public const string TypePropertyName = "type";
public const string PropertiesPropertyName = "properties";
public const string ItemsPropertyName = "items";
- public const string OptionalPropertyName = "optional";
+ public const string RequiredPropertyName = "required";
public const string AdditionalPropertiesPropertyName = "additionalProperties";
public const string RequiresPropertyName = "requires";
public const string IdentityPropertyName = "identity";
@@ -54,7 +54,7 @@ namespace Newtonsoft.Json.Schema
public const string FormatPropertyName = "format";
public const string DefaultPropertyName = "default";
public const string TransientPropertyName = "transient";
- public const string MaximumDecimalsPropertyName = "maxDecimal";
+ public const string DivisibleByPropertyName = "divisibleBy";
public const string HiddenPropertyName = "hidden";
public const string DisallowPropertyName = "disallow";
public const string ExtendsPropertyName = "extends";
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
index f906ebb..feb6a41 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
@@ -205,7 +205,7 @@ namespace Newtonsoft.Json.Schema
}
}
- private JsonSchema GenerateInternal(Type type, Required valueRequired, bool optional)
+ private JsonSchema GenerateInternal(Type type, Required valueRequired, bool required)
{
ValidationUtils.ArgumentNotNull(type, "type");
@@ -221,8 +221,8 @@ namespace Newtonsoft.Json.Schema
// change resolved schema to allow nulls. hacky but what are ya gonna do?
if (valueRequired != Required.Always && !HasFlag(resolvedSchema.Type, JsonSchemaType.Null))
resolvedSchema.Type |= JsonSchemaType.Null;
- if (optional && resolvedSchema.Optional != true)
- resolvedSchema.Optional = true;
+ if (required && resolvedSchema.Required != true)
+ resolvedSchema.Required = true;
return resolvedSchema;
}
@@ -248,8 +248,8 @@ namespace Newtonsoft.Json.Schema
if (explicitId != null)
CurrentSchema.Id = explicitId;
- if (optional)
- CurrentSchema.Optional = true;
+ if (required)
+ CurrentSchema.Required = true;
CurrentSchema.Title = GetTitle(type);
CurrentSchema.Description = GetDescription(type);
@@ -364,7 +364,7 @@ namespace Newtonsoft.Json.Schema
property.ShouldSerialize != null ||
property.GetIsSpecified != null;
- JsonSchema propertySchema = GenerateInternal(property.PropertyType, property.Required, optional);
+ JsonSchema propertySchema = GenerateInternal(property.PropertyType, property.Required, !optional);
if (property.DefaultValue != null)
propertySchema.Default = JToken.FromObject(property.DefaultValue);
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaModel.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaModel.cs
index 26e1ae2..c817669 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaModel.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaModel.cs
@@ -33,11 +33,11 @@ namespace Newtonsoft.Json.Schema
{
internal class JsonSchemaModel
{
- public bool Optional { get; set; }
+ public bool Required { get; set; }
public JsonSchemaType Type { get; set; }
public int? MinimumLength { get; set; }
public int? MaximumLength { get; set; }
- public int? MaximumDecimals { get; set; }
+ public double? DivisibleBy { get; set; }
public double? Minimum { get; set; }
public double? Maximum { get; set; }
public int? MinimumItems { get; set; }
@@ -54,7 +54,7 @@ namespace Newtonsoft.Json.Schema
{
Type = JsonSchemaType.Any;
AllowAdditionalProperties = true;
- Optional = true;
+ Required = false;
}
public static JsonSchemaModel Create(IList<JsonSchema> schemata)
@@ -71,12 +71,16 @@ namespace Newtonsoft.Json.Schema
private static void Combine(JsonSchemaModel model, JsonSchema schema)
{
- model.Optional = model.Optional && (schema.Optional ?? false);
+ // Version 3 of the Draft JSON Schema has the default value of Not Required
+ model.Required = model.Required || (schema.Required ?? false);
model.Type = model.Type & (schema.Type ?? JsonSchemaType.Any);
model.MinimumLength = MathUtils.Max(model.MinimumLength, schema.MinimumLength);
model.MaximumLength = MathUtils.Min(model.MaximumLength, schema.MaximumLength);
- model.MaximumDecimals = MathUtils.Min(model.MaximumDecimals, schema.MaximumDecimals);
+
+ // not sure what is the best way to combine divisibleBy
+ model.DivisibleBy = MathUtils.Max(model.DivisibleBy, schema.DivisibleBy);
+
model.Minimum = MathUtils.Max(model.Minimum, schema.Minimum);
model.Maximum = MathUtils.Max(model.Maximum, schema.Maximum);
model.MinimumItems = MathUtils.Max(model.MinimumItems, schema.MinimumItems);
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaWriter.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaWriter.cs
index c3f9d50..c561e5f 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaWriter.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaWriter.cs
@@ -70,7 +70,7 @@ namespace Newtonsoft.Json.Schema
WritePropertyIfNotNull(_writer, JsonSchemaConstants.IdPropertyName, schema.Id);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.TitlePropertyName, schema.Title);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.DescriptionPropertyName, schema.Description);
- WritePropertyIfNotNull(_writer, JsonSchemaConstants.OptionalPropertyName, schema.Optional);
+ WritePropertyIfNotNull(_writer, JsonSchemaConstants.RequiredPropertyName, schema.Required);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.ReadOnlyPropertyName, schema.ReadOnly);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.HiddenPropertyName, schema.Hidden);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.TransientPropertyName, schema.Transient);
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Schema
WritePropertyIfNotNull(_writer, JsonSchemaConstants.MaximumLengthPropertyName, schema.MaximumLength);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.MinimumItemsPropertyName, schema.MinimumItems);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.MaximumItemsPropertyName, schema.MaximumItems);
- WritePropertyIfNotNull(_writer, JsonSchemaConstants.MaximumDecimalsPropertyName, schema.MaximumDecimals);
+ WritePropertyIfNotNull(_writer, JsonSchemaConstants.DivisibleByPropertyName, schema.DivisibleBy);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.FormatPropertyName, schema.Format);
WritePropertyIfNotNull(_writer, JsonSchemaConstants.PatternPropertyName, schema.Pattern);
if (schema.Enum != null)
diff --git a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
index f8eccf8..2483de3 100644
--- a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
+++ b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
@@ -743,8 +743,8 @@ namespace Newtonsoft.Json.Serialization
specifiedMember = member.DeclaringType.GetField(member.Name + JsonTypeReflector.SpecifiedPostfix);
if (specifiedMember == null || ReflectionUtils.GetMemberUnderlyingType(specifiedMember) != typeof(bool)
- || (ReflectionUtils.GetAttribute<XmlIgnoreAttribute>(specifiedMember) != null
- && ReflectionUtils.GetAttribute<JsonIgnoreAttribute>(specifiedMember) != null))
+ || (ReflectionUtils.GetAttribute<XmlIgnoreAttribute>(specifiedMember) == null
+ && ReflectionUtils.GetAttribute<JsonIgnoreAttribute>(specifiedMember) == null))
{
return;
}
diff --git a/Tools/NuGet/NuGet.exe b/Tools/NuGet/NuGet.exe
index 9b66d59..907d24d 100644
--- a/Tools/NuGet/NuGet.exe
+++ b/Tools/NuGet/NuGet.exe
Binary files differ