From a61d14b095485803911723b06e5bf46e9a0bbc74 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Wed, 17 Aug 2022 11:05:47 -0700 Subject: [PATCH] Update Newtonsoft.Json to 13.0.1 (#43157) * Update Newtonsoft.Json to 13.0.1 * Set JsonTextReader's MaxDepth to null In v13, defaults are changed from null to 64. --- eng/Versions.props | 2 +- src/System.Text.Json/tests/JsonDocumentTests.cs | 4 ++-- src/System.Text.Json/tests/JsonTestHelper.cs | 10 +++++----- .../tests/Utf8JsonReaderTests.TryGet.cs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index c80f5792add8..3e08bde1c1c2 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -71,7 +71,7 @@ 2.4.1 2.0.5 1.0.31 - 12.0.1 + 13.0.1 3.0.0-preview6-27804-01 5.0.0-beta.20105.1 diff --git a/src/System.Text.Json/tests/JsonDocumentTests.cs b/src/System.Text.Json/tests/JsonDocumentTests.cs index 0915aa9d2e0c..f1a7402aa7e7 100644 --- a/src/System.Text.Json/tests/JsonDocumentTests.cs +++ b/src/System.Text.Json/tests/JsonDocumentTests.cs @@ -556,7 +556,7 @@ private static void ParseJson( using (var stream = new MemoryStream(dataUtf8)) using (var streamReader = new StreamReader(stream, Encoding.UTF8, false, 1024, true)) - using (JsonTextReader jsonReader = new JsonTextReader(streamReader)) + using (JsonTextReader jsonReader = new JsonTextReader(streamReader) { MaxDepth = null }) { JToken jToken = JToken.ReadFrom(jsonReader); @@ -3662,7 +3662,7 @@ private static string GetCompactJson(TestCaseType testCaseType, string jsonStrin return existing; } - using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(jsonString))) + using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }) { jsonReader.FloatParseHandling = FloatParseHandling.Decimal; JToken jtoken = JToken.ReadFrom(jsonReader); diff --git a/src/System.Text.Json/tests/JsonTestHelper.cs b/src/System.Text.Json/tests/JsonTestHelper.cs index 739f3ba07991..9f9540781af4 100644 --- a/src/System.Text.Json/tests/JsonTestHelper.cs +++ b/src/System.Text.Json/tests/JsonTestHelper.cs @@ -29,7 +29,7 @@ internal static class JsonTestHelper public static string NewtonsoftReturnStringHelper(TextReader reader) { var sb = new StringBuilder(); - var json = new JsonTextReader(reader); + var json = new JsonTextReader(reader) { MaxDepth = null }; while (json.Read()) { if (json.Value != null) @@ -345,7 +345,7 @@ public static string InsertCommentsEverywhere(string jsonString) { writer.Formatting = Formatting.Indented; - var newtonsoft = new JsonTextReader(new StringReader(jsonString)); + var newtonsoft = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }; writer.WriteComment("comment"); while (newtonsoft.Read()) { @@ -359,7 +359,7 @@ public static string InsertCommentsEverywhere(string jsonString) public static List GetTokenTypes(string jsonString) { - var newtonsoft = new JsonTextReader(new StringReader(jsonString)); + var newtonsoft = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }; int totalReads = 0; while (newtonsoft.Read()) { @@ -370,7 +370,7 @@ public static List GetTokenTypes(string jsonString) for (int i = 0; i < totalReads; i++) { - newtonsoft = new JsonTextReader(new StringReader(jsonString)); + newtonsoft = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }; for (int j = 0; j < i; j++) { Assert.True(newtonsoft.Read()); @@ -690,7 +690,7 @@ public static decimal NextDecimal(Random random, double minValue, double maxValu public static string GetCompactString(string jsonString) { - using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(jsonString))) + using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }) { jsonReader.FloatParseHandling = FloatParseHandling.Decimal; JToken jtoken = JToken.ReadFrom(jsonReader); diff --git a/src/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs b/src/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs index b8bd527cad11..72a561b422e6 100644 --- a/src/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs +++ b/src/System.Text.Json/tests/Utf8JsonReaderTests.TryGet.cs @@ -1026,7 +1026,7 @@ public static void TestingGetString(string jsonString) var expectedPropertyNames = new List(); var expectedValues = new List(); - var jsonNewtonsoft = new JsonTextReader(new StringReader(jsonString)); + var jsonNewtonsoft = new JsonTextReader(new StringReader(jsonString)) { MaxDepth = null }; while (jsonNewtonsoft.Read()) { if (jsonNewtonsoft.TokenType == JsonToken.String)