diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 9f8f20b..0edd1ac 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -11,7 +11,7 @@ jobs: strategy: matrix: build-configuration: [ Debug, Release ] - test-target-framework: [ net6.0, net5.0, netcoreapp3.1 ] + test-target-framework: [ net8.0, net7.0, net6.0 ] name: Build And Test (${{ matrix.test-target-framework }}, ${{ matrix.build-configuration }}) runs-on: ubuntu-latest steps: @@ -20,9 +20,9 @@ jobs: uses: actions/setup-dotnet@v2 with: dotnet-version: | + 8.x + 7.x 6.x - 5.x - 3.1.x - name: Restore run: dotnet restore ${{ env.JsonDiffPatchSolutionPath }} - name: Build diff --git a/README.md b/README.md index 0947e19..1ed55e9 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,12 @@ High-performance, low-allocating JSON object diff and patch extension for System - Compatible with [jsondiffpatch delta format](https://github.com/benjamine/jsondiffpatch/blob/master/docs/deltas.md) - Support generating patch document in RFC 6902 JSON Patch format -- Target latest **.NET Standard** and **.NET Framework 4.6.1** (for legacy apps) and leverage latest .NET features +- Support .NET and .NET Framework - Alternative to [jsondiffpatch.net](https://github.com/wbish/jsondiffpatch.net) which is based on Newtonsoft.Json - Fast large JSON document diffing with less memory consumption (see [benchmark](https://github.com/weichch/system-text-json-jsondiffpatch/blob/main/Benchmark.md)) - Support smart array diffing (e.g. move detect) using LCS (Longest Common Subsequence) and custom array item matcher - _(Only when not using RFC 6902 format)_ Support diffing long text using [google-diff-match-patch](http://code.google.com/p/google-diff-match-patch/), or write your own diff algorithm - Bonus `DeepEquals` method for comparing `JsonDocument`, `JsonElement` and `JsonNode` -- Bonus `DeepClone` method - Bonus [`JsonValueComparer`](https://github.com/weichch/system-text-json-jsondiffpatch/blob/main/src/SystemTextJson.JsonDiffPatch/JsonValueComparer.cs) that implements semantic comparison of two `JsonValue` objects - JSON assert for xUnit, MSTest v2 and NUnit with customizable delta output @@ -44,7 +43,7 @@ PM> Install-Package SystemTextJson.JsonDiffPatch.MSTest PM> Install-Package SystemTextJson.JsonDiffPatch.NUnit ``` -## Usage +## Examples ### Diff @@ -106,13 +105,6 @@ var textEqual = node1.DeepEquals(node2, JsonElementComparison.RawText); var semanticEqual = node1.DeepEquals(node2, JsonElementComparison.Semantic); ``` -### DeepClone - -```csharp -var node = JsonNode.Parse("{\"foo\":\"bar\"}"); -var cloned = node.DeepClone(); -``` - ### Default Options ```csharp diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8e0b1b9..231e045 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,18 @@ # Release Notes +## 2.0.0 + +- This version contains several **BREAKING CHANGES**: + - **Targeting framework changes**: + - Added: .NET 8, .NET 7, .NET 6, .NET Framework 4.6.2 + - Removed: .NET Standard 2.1, .NET Framework 4.6.1 + - Minimum version of `System.Text.Json` required is bumped up to `8.0.0` + - `JsonDiffPatcher.DeepEquals(JsonNode)` now simply calls `JsonNode.DeepEquals(JsonNode, JsonNode)` method introduced in [this issue](https://github.com/dotnet/runtime/issues/56592) + - `JsonDiffPatcher.Diff` method is unchanged because it does not use `JsonNode.DeepEquals(JsonNode, JsonNode)` method internally + - You can still use `JsonDiffPatcher.DeepEquals` method when invoked with custom comparison options + - When invoked against `JsonDocument` and `JsonElement`, `DeepEquals` method is unchanged + - Removed `JsonDiffPatcher.DeepClone` method. You can migrate to `JsonNode.DeepClone` method introduced in [this issue](https://github.com/dotnet/runtime/issues/56592) + ## 1.3.1 - Added `PropertyFilter` to `JsonDiffOptions` (#29) diff --git a/THIRD-PARTY-NOTICES.txt b/THIRD-PARTY-NOTICES.txt index 8c0b939..3d2deae 100644 --- a/THIRD-PARTY-NOTICES.txt +++ b/THIRD-PARTY-NOTICES.txt @@ -2,7 +2,9 @@ system-text-json-jsondiffpatch uses third-party libraries or other resources tha distributed under licenses different than system-text-json-jsondiffpatch. In the event that we accidentally failed to list a required notice, please -bring it to our attention. Please post an issue. +bring it to our attention. + +Please post an issue at https://github.com/weichch/system-text-json-jsondiffpatch/issues The attached notices are provided for information only. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a58122d..8cb48b8 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@  - netstandard2.0;netstandard2.1;net461 + net8.0;net7.0;net6.0;netstandard2.0;net462 enable latest true @@ -9,10 +9,10 @@ - 1.3.1 + 2.0.0 Wei Chen https://github.com/weichch/system-text-json-jsondiffpatch - Copyright © Wei Chen 2022 + Copyright © Wei Chen 2024 icon.png LICENSE https://github.com/weichch/system-text-json-jsondiffpatch/blob/$(JsonDiffPatchPackageVersion)/ReleaseNotes.md @@ -27,6 +27,7 @@ + diff --git a/src/SystemTextJson.JsonDiffPatch.MSTest/JsonAssert.cs b/src/SystemTextJson.JsonDiffPatch.MSTest/JsonAssert.cs index f24b52d..9fd6663 100644 --- a/src/SystemTextJson.JsonDiffPatch.MSTest/JsonAssert.cs +++ b/src/SystemTextJson.JsonDiffPatch.MSTest/JsonAssert.cs @@ -1,4 +1,5 @@ using System.Text.Json.Nodes; +using System.Text.Json.Serialization.Metadata; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace System.Text.Json.JsonDiffPatch.MsTest @@ -8,7 +9,18 @@ namespace System.Text.Json.JsonDiffPatch.MsTest /// public static class JsonAssert { - private static readonly JsonSerializerOptions SerializerOptions = new() {WriteIndented = true}; + private static readonly JsonSerializerOptions SerializerOptions; + + static JsonAssert() + { + SerializerOptions = new() + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + WriteIndented = true + }; + + SerializerOptions.MakeReadOnly(); + } /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, diff --git a/src/SystemTextJson.JsonDiffPatch.NUnit/JsonAssert.cs b/src/SystemTextJson.JsonDiffPatch.NUnit/JsonAssert.cs index b1ff3a0..3534a1a 100644 --- a/src/SystemTextJson.JsonDiffPatch.NUnit/JsonAssert.cs +++ b/src/SystemTextJson.JsonDiffPatch.NUnit/JsonAssert.cs @@ -1,4 +1,5 @@ using System.Text.Json.Nodes; +using System.Text.Json.Serialization.Metadata; using NUnit.Framework; namespace System.Text.Json.JsonDiffPatch.Nunit @@ -8,7 +9,18 @@ namespace System.Text.Json.JsonDiffPatch.Nunit /// public static class JsonAssert { - private static readonly JsonSerializerOptions SerializerOptions = new() {WriteIndented = true}; + private static readonly JsonSerializerOptions SerializerOptions; + + static JsonAssert() + { + SerializerOptions = new() + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + WriteIndented = true + }; + + SerializerOptions.MakeReadOnly(); + } /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, @@ -179,7 +191,7 @@ public static void JsonAreEqual(this Assert assert, string? expected, string? ac /// Whether to print diff result. public static void JsonAreEqual(this Assert assert, string? expected, string? actual, bool output) => AreEqual(expected, actual, output); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -191,7 +203,7 @@ public static void JsonAreEqual(this Assert assert, string? expected, string? ac public static void JsonAreEqual(this Assert assert, string? expected, string? actual, JsonDiffOptions diffOptions) => AreEqual(expected, actual, diffOptions); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -204,7 +216,7 @@ public static void JsonAreEqual(this Assert assert, string? expected, string? ac public static void JsonAreEqual(this Assert assert, string? expected, string? actual, JsonDiffOptions diffOptions, bool output) => AreEqual(expected, actual, diffOptions, output); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -230,7 +242,7 @@ public static void JsonAreEqual(this Assert assert, string? expected, string? ac JsonDiffOptions diffOptions, Func outputFormatter) => AreEqual(expected, actual, diffOptions, outputFormatter); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -242,7 +254,7 @@ public static void JsonAreEqual(this Assert assert, string? expected, string? ac public static void JsonAreEqual(this Assert assert, T? expected, T? actual) where T : JsonNode => AreEqual(expected, actual); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -255,7 +267,7 @@ public static void JsonAreEqual(this Assert assert, T? expected, T? actual) public static void JsonAreEqual(this Assert assert, T? expected, T? actual, bool output) where T : JsonNode => AreEqual(expected, actual, output); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -268,7 +280,7 @@ public static void JsonAreEqual(this Assert assert, T? expected, T? actual, b public static void JsonAreEqual(this Assert assert, T? expected, T? actual, JsonDiffOptions diffOptions) where T : JsonNode => AreEqual(expected, actual, diffOptions); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -283,7 +295,7 @@ public static void JsonAreEqual(this Assert assert, T? expected, T? actual, JsonDiffOptions diffOptions, bool output) where T : JsonNode => AreEqual(expected, actual, diffOptions, output); - + /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -378,7 +390,7 @@ public static void AreNotEqual(string? expected, string? actual) public static void AreNotEqual(string? expected, string? actual, JsonDiffOptions diffOptions) => AreNotEqual(expected is null ? null : JsonNode.Parse(expected), actual is null ? null : JsonNode.Parse(actual), diffOptions); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -389,7 +401,7 @@ public static void AreNotEqual(string? expected, string? actual, JsonDiffOptions public static void AreNotEqual(T? expected, T? actual) where T : JsonNode => HandleAreNotEqual(expected, actual, null); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -402,7 +414,7 @@ public static void AreNotEqual(T? expected, T? actual, JsonDiffOptions diffOp where T : JsonNode => HandleAreNotEqual(expected, actual, diffOptions ?? throw new ArgumentNullException(nameof(diffOptions))); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -412,7 +424,7 @@ public static void AreNotEqual(T? expected, T? actual, JsonDiffOptions diffOp /// The actual value. public static void JsonAreNotEqual(this Assert assert, string? expected, string? actual) => AreNotEqual(expected, actual); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -424,7 +436,7 @@ public static void JsonAreNotEqual(this Assert assert, string? expected, string? public static void JsonAreNotEqual(this Assert assert, string? expected, string? actual, JsonDiffOptions diffOptions) => AreNotEqual(expected, actual, diffOptions); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. @@ -436,7 +448,7 @@ public static void JsonAreNotEqual(this Assert assert, string? expected, string? public static void JsonAreNotEqual(this Assert assert, T? expected, T? actual) where T : JsonNode => AreNotEqual(expected, actual); - + /// /// Tests whether two JSON objects are not equal. Note that when comparing the specified objects, /// the ordering of members in the objects is not significant. diff --git a/src/SystemTextJson.JsonDiffPatch.Xunit/JsonAssert.cs b/src/SystemTextJson.JsonDiffPatch.Xunit/JsonAssert.cs index fcc56d5..81b5ee4 100644 --- a/src/SystemTextJson.JsonDiffPatch.Xunit/JsonAssert.cs +++ b/src/SystemTextJson.JsonDiffPatch.Xunit/JsonAssert.cs @@ -1,4 +1,5 @@ using System.Text.Json.Nodes; +using System.Text.Json.Serialization.Metadata; namespace System.Text.Json.JsonDiffPatch.Xunit { @@ -7,7 +8,18 @@ namespace System.Text.Json.JsonDiffPatch.Xunit /// public static class JsonAssert { - private static readonly JsonSerializerOptions SerializerOptions = new() {WriteIndented = true}; + private static readonly JsonSerializerOptions SerializerOptions; + + static JsonAssert() + { + SerializerOptions = new() + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + WriteIndented = true + }; + + SerializerOptions.MakeReadOnly(); + } /// /// Tests whether two JSON objects are equal. Note that when comparing the specified objects, diff --git a/src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffDelta.cs b/src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffDelta.cs index 5300504..7cbd5dc 100644 --- a/src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffDelta.cs +++ b/src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffDelta.cs @@ -244,22 +244,22 @@ public void Added(JsonNode? newValue) { EnsureDeltaType(nameof(Added), count: 1); var arr = Document!.AsArray(); - arr[0] = newValue.DeepClone(); + arr[0] = newValue?.DeepClone(); } public void Modified(JsonNode? oldValue, JsonNode? newValue) { EnsureDeltaType(nameof(Modified), count: 2); var arr = Document!.AsArray(); - arr[0] = oldValue.DeepClone(); - arr[1] = newValue.DeepClone(); + arr[0] = oldValue?.DeepClone(); + arr[1] = newValue?.DeepClone(); } public void Deleted(JsonNode? oldValue) { EnsureDeltaType(nameof(Deleted), count: 3, opType: OpTypeDeleted); var arr = Document!.AsArray(); - arr[0] = oldValue.DeepClone(); + arr[0] = oldValue?.DeepClone(); arr[1] = 0; } diff --git a/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.Clone.cs b/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.Clone.cs deleted file mode 100644 index 8296cca..0000000 --- a/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.Clone.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json.Nodes; - -namespace System.Text.Json.JsonDiffPatch -{ - static partial class JsonDiffPatcher - { - /// - /// Creates a deep copy of the . - /// - /// The . - public static T? DeepClone(this T? obj) where T : JsonNode - { - return (T?)(obj switch - { - null => (JsonNode?)null, - JsonObject jsonObj => new JsonObject(Enumerate(jsonObj), obj.Options), - JsonArray array => CloneArray(array), - JsonValue value => CloneJsonValue(value), - _ => throw new NotSupportedException( - $"JsonNode of type '{obj.GetType().Name}' is not supported.") - }); - - static IEnumerable> Enumerate(JsonObject obj) - { - foreach (var kvp in obj) - { - yield return new KeyValuePair(kvp.Key, kvp.Value.DeepClone()); - } - } - } - - private static JsonValue? CloneJsonValue(JsonValue? value) - { - if (value is null) - { - return null; - } - - if (value.TryGetValue(out var element)) - return JsonValue.Create(element.Clone(), value.Options); - if (value.TryGetValue(out var intValue)) - return JsonValue.Create(intValue, value.Options); - if (value.TryGetValue(out var longValue)) - return JsonValue.Create(longValue, value.Options); - if (value.TryGetValue(out var doubleValue)) - return JsonValue.Create(doubleValue, value.Options); - if (value.TryGetValue(out var shortValue)) - return JsonValue.Create(shortValue, value.Options); - if (value.TryGetValue(out var decimalValue)) - return JsonValue.Create(decimalValue, value.Options); - if (value.TryGetValue(out var byteValue)) - return JsonValue.Create(byteValue, value.Options); - if (value.TryGetValue(out var floatValue)) - return JsonValue.Create(floatValue, value.Options); - if (value.TryGetValue(out var uintValue)) - return JsonValue.Create(uintValue, value.Options); - if (value.TryGetValue(out var ushortValue)) - return JsonValue.Create(ushortValue, value.Options); - if (value.TryGetValue(out var ulongValue)) - return JsonValue.Create(ulongValue, value.Options); - if (value.TryGetValue(out var sbyteValue)) - return JsonValue.Create(sbyteValue, value.Options); - if (value.TryGetValue(out var stringValue)) - return JsonValue.Create(stringValue, value.Options); - if (value.TryGetValue(out var dateTimeValue)) - return JsonValue.Create(dateTimeValue, value.Options); - if (value.TryGetValue(out var dateTimeOffsetValue)) - return JsonValue.Create(dateTimeOffsetValue, value.Options); - if (value.TryGetValue(out var guidValue)) - return JsonValue.Create(guidValue, value.Options); - if (value.TryGetValue(out var charValue)) - return JsonValue.Create(charValue, value.Options); - if (value.TryGetValue(out var byteArrayValue)) - return JsonValue.Create(byteArrayValue, value.Options); - - // Perf: This is slower than direct property access - return JsonValue.Create(value.GetValue(), value.Options); - } - - private static JsonArray CloneArray(JsonArray arr) - { - var newArr = new JsonArray(arr.Options); - foreach (var cloned in arr.Select(DeepClone)) - { - newArr.Add(cloned); - } - - return newArr; - } - } -} diff --git a/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.DeepEquals.cs b/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.DeepEquals.cs index 89f64e8..bbcb02d 100644 --- a/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.DeepEquals.cs +++ b/src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.DeepEquals.cs @@ -7,13 +7,13 @@ namespace System.Text.Json.JsonDiffPatch static partial class JsonDiffPatcher { /// - /// Determines whether two objects are deeply equal. + /// Invokes method. /// /// The left value. /// The right value. public static bool DeepEquals(this JsonNode? left, JsonNode? right) { - return DeepEquals(left, right, default(JsonComparerOptions)); + return JsonNode.DeepEquals(left, right); } /// diff --git a/src/SystemTextJson.JsonDiffPatch/JsonString.cs b/src/SystemTextJson.JsonDiffPatch/JsonString.cs index dcf540d..8efade0 100644 --- a/src/SystemTextJson.JsonDiffPatch/JsonString.cs +++ b/src/SystemTextJson.JsonDiffPatch/JsonString.cs @@ -2,15 +2,24 @@ using System.Runtime.CompilerServices; using System.Text.Encodings.Web; using System.Text.Json.Nodes; +using System.Text.Json.Serialization.Metadata; namespace System.Text.Json.JsonDiffPatch { internal struct JsonString { - internal static readonly JsonSerializerOptions SerializerOptions = new() + internal static readonly JsonSerializerOptions SerializerOptions; + + static JsonString() { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }; + SerializerOptions = new() + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + + SerializerOptions.MakeReadOnly(); + } private DateTime? _dateTimeValue; private DateTimeOffset? _dateTimeOffsetValue; diff --git a/src/SystemTextJson.JsonDiffPatch/Patching/JsonDiffPatcher.Patch.cs b/src/SystemTextJson.JsonDiffPatch/Patching/JsonDiffPatcher.Patch.cs index b51f1d3..f75b9ff 100644 --- a/src/SystemTextJson.JsonDiffPatch/Patching/JsonDiffPatcher.Patch.cs +++ b/src/SystemTextJson.JsonDiffPatch/Patching/JsonDiffPatcher.Patch.cs @@ -52,7 +52,7 @@ when left is JsonValue jsonValue /// The patch options. public static JsonNode? PatchNew(this JsonNode? left, JsonNode? patch, JsonPatchOptions options = default) { - var copy = left.DeepClone(); + var copy = left?.DeepClone(); Patch(ref copy, patch, options); return copy; } @@ -105,7 +105,7 @@ when right is JsonValue jsonValue /// The patch options. public static JsonNode? ReversePatchNew(this JsonNode? right, JsonNode? patch, JsonReversePatchOptions options = default) { - var copy = right.DeepClone(); + var copy = right?.DeepClone(); ReversePatch(ref copy, patch, options); return copy; } diff --git a/src/SystemTextJson.JsonDiffPatch/SystemTextJson.JsonDiffPatch.csproj b/src/SystemTextJson.JsonDiffPatch/SystemTextJson.JsonDiffPatch.csproj index 4bb32a1..a92ba95 100644 --- a/src/SystemTextJson.JsonDiffPatch/SystemTextJson.JsonDiffPatch.csproj +++ b/src/SystemTextJson.JsonDiffPatch/SystemTextJson.JsonDiffPatch.csproj @@ -11,11 +11,11 @@ - + - + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 41d357d..6c40006 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,5 +1,9 @@  + + net8.0;net7.0;net6.0;net48 + + false enable diff --git a/test/SystemTextJson.JsonDiffPatch.Benchmark/DeepCloneJsonFileBenchmark.cs b/test/SystemTextJson.JsonDiffPatch.Benchmark/DeepCloneJsonFileBenchmark.cs deleted file mode 100644 index f27d956..0000000 --- a/test/SystemTextJson.JsonDiffPatch.Benchmark/DeepCloneJsonFileBenchmark.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Text.Json.JsonDiffPatch; -using System.Text.Json.Nodes; -using BenchmarkDotNet.Attributes; -using Newtonsoft.Json.Linq; - -namespace SystemTextJson.JsonDiffPatch.Benchmark -{ - public class DeepCloneJsonFileBenchmark : JsonFileBenchmark - { - [Benchmark] - public JsonNode SystemTextJson() - { - return JsonNode.Parse(JsonLeft).DeepClone()!; - } - - [Benchmark] - public JToken JsonNet() - { - return JToken.Parse(JsonLeft).DeepClone(); - } - } -} diff --git a/test/SystemTextJson.JsonDiffPatch.Benchmark/SystemTextJson.JsonDiffPatch.Benchmark.csproj b/test/SystemTextJson.JsonDiffPatch.Benchmark/SystemTextJson.JsonDiffPatch.Benchmark.csproj index 3f3c722..c13337c 100644 --- a/test/SystemTextJson.JsonDiffPatch.Benchmark/SystemTextJson.JsonDiffPatch.Benchmark.csproj +++ b/test/SystemTextJson.JsonDiffPatch.Benchmark/SystemTextJson.JsonDiffPatch.Benchmark.csproj @@ -2,14 +2,13 @@ Exe - net6.0;net48 true - + - + diff --git a/test/SystemTextJson.JsonDiffPatch.MSTest.Tests/SystemTextJson.JsonDiffPatch.MSTest.Tests.csproj b/test/SystemTextJson.JsonDiffPatch.MSTest.Tests/SystemTextJson.JsonDiffPatch.MSTest.Tests.csproj index 7db3076..644d848 100644 --- a/test/SystemTextJson.JsonDiffPatch.MSTest.Tests/SystemTextJson.JsonDiffPatch.MSTest.Tests.csproj +++ b/test/SystemTextJson.JsonDiffPatch.MSTest.Tests/SystemTextJson.JsonDiffPatch.MSTest.Tests.csproj @@ -1,14 +1,10 @@  - - netcoreapp3.1;net5.0;net6.0;net461;net48 - - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/SystemTextJson.JsonDiffPatch.NUnit.Tests/SystemTextJson.JsonDiffPatch.NUnit.Tests.csproj b/test/SystemTextJson.JsonDiffPatch.NUnit.Tests/SystemTextJson.JsonDiffPatch.NUnit.Tests.csproj index 63a5b31..8e84012 100644 --- a/test/SystemTextJson.JsonDiffPatch.NUnit.Tests/SystemTextJson.JsonDiffPatch.NUnit.Tests.csproj +++ b/test/SystemTextJson.JsonDiffPatch.NUnit.Tests/SystemTextJson.JsonDiffPatch.NUnit.Tests.csproj @@ -1,14 +1,10 @@  - - netcoreapp3.1;net5.0;net6.0;net461;net48 - - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/SystemTextJson.JsonDiffPatch.UnitTests/DemoFileTests.cs b/test/SystemTextJson.JsonDiffPatch.UnitTests/DemoFileTests.cs index 57fbf99..343b142 100644 --- a/test/SystemTextJson.JsonDiffPatch.UnitTests/DemoFileTests.cs +++ b/test/SystemTextJson.JsonDiffPatch.UnitTests/DemoFileTests.cs @@ -74,10 +74,10 @@ public void Roundtrip_DemoFile() Assert.Null(left.Diff(originalLeft, diffOptions)); JsonDiffPatcher.Patch(ref left, diff); - Assert.True(left.DeepEquals(right)); + Assert.True(left.DeepEquals(right, default(JsonComparerOptions))); JsonDiffPatcher.ReversePatch(ref left, diff); - Assert.True(left.DeepEquals(originalLeft)); + Assert.True(left.DeepEquals(originalLeft, default(JsonComparerOptions))); } [Fact] @@ -89,7 +89,7 @@ public void Diff_DemoJson_JsonPatch() @"Examples/demo_right.json", new JsonPatchDeltaFormatter()); - Assert.True(expectedDiff.DeepEquals(diff)); + Assert.True(expectedDiff.DeepEquals(diff, default(JsonComparerOptions))); } [Fact] @@ -121,10 +121,10 @@ public void Roundtrip_LargeObjects() Assert.Null(left.Diff(originalLeft, diffOptions)); JsonDiffPatcher.Patch(ref left, diff); - Assert.True(left.DeepEquals(right)); + Assert.True(left.DeepEquals(right, default(JsonComparerOptions))); JsonDiffPatcher.ReversePatch(ref left, diff); - Assert.True(left.DeepEquals(originalLeft)); + Assert.True(left.DeepEquals(originalLeft, default(JsonComparerOptions))); } [Fact] @@ -136,7 +136,7 @@ public void Diff_LargeObjects_JsonPatch() @"Examples/large_right.json", new JsonPatchDeltaFormatter()); - Assert.True(expectedDiff.DeepEquals(diff)); + Assert.True(expectedDiff.DeepEquals(diff, default(JsonComparerOptions))); } } } diff --git a/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ElementDeepEqualsTests.cs b/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ElementDeepEqualsTests.cs index 95c60e9..44c96c7 100644 --- a/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ElementDeepEqualsTests.cs +++ b/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ElementDeepEqualsTests.cs @@ -12,7 +12,7 @@ public void Object_Identical() var json1 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); var json2 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -21,7 +21,7 @@ public void Object_Whitespace() var json1 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); var json2 = JsonNode.Parse("{ \"foo\": \"bar\", \"baz\":\"qux\" }"); - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -30,7 +30,7 @@ public void Object_PropertyOrdering() var json1 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); var json2 = JsonNode.Parse("{\"baz\":\"qux\",\"foo\":\"bar\"}"); - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -39,7 +39,7 @@ public void Object_PropertyValue() var json1 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); var json2 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"quz\"}"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -48,7 +48,7 @@ public void Object_MissingProperty() var json1 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); var json2 = JsonNode.Parse("{\"foo\":\"bar\"}"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -57,7 +57,7 @@ public void Object_ExtraProperty() var json1 = JsonNode.Parse("{\"foo\":\"bar\"}"); var json2 = JsonNode.Parse("{\"foo\":\"bar\",\"baz\":\"qux\"}"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -66,7 +66,7 @@ public void Array_Identical() var json1 = JsonNode.Parse("[1,2,3]"); var json2 = JsonNode.Parse("[1,2,3]"); - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -75,7 +75,7 @@ public void Array_Whitespace() var json1 = JsonNode.Parse("[1,2,3]"); var json2 = JsonNode.Parse("[ 1, 2, 3 ]"); - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -84,7 +84,7 @@ public void Array_ItemOrdering() var json1 = JsonNode.Parse("[1,2,3]"); var json2 = JsonNode.Parse("[1,3,2]"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -93,7 +93,7 @@ public void Array_ItemValue() var json1 = JsonNode.Parse("[1,2,3]"); var json2 = JsonNode.Parse("[1,2,5]"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -102,7 +102,7 @@ public void Array_MissingItem() var json1 = JsonNode.Parse("[1,2,3]"); var json2 = JsonNode.Parse("[1,2]"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -111,14 +111,14 @@ public void Array_ExtraItem() var json1 = JsonNode.Parse("[1,2]"); var json2 = JsonNode.Parse("[1,2,3]"); - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Theory] [MemberData(nameof(NodeTestData.ElementRawTextEqual), MemberType = typeof(NodeTestData))] public void Value_RawText(JsonValue json1, JsonValue json2, bool expected) { - Assert.Equal(expected, json1.DeepEquals(json2)); + Assert.Equal(expected, json1.DeepEquals(json2, default(JsonComparerOptions))); } [Theory] @@ -132,7 +132,7 @@ public void Value_Semantic(JsonValue json1, JsonValue json2, bool expected) [MemberData(nameof(NodeTestData.ElementObjectSemanticEqual), MemberType = typeof(NodeTestData))] public void Value_ElementObjectSemanticEqual(JsonValue json1, JsonValue json2, bool expected) { - Assert.Equal(expected, json1.DeepEquals(json2)); + Assert.Equal(expected, json1.DeepEquals(json2, default(JsonComparerOptions))); } } } diff --git a/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ObjectDeepEqualsTests.cs b/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ObjectDeepEqualsTests.cs index 3278e1e..719d9e3 100644 --- a/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ObjectDeepEqualsTests.cs +++ b/test/SystemTextJson.JsonDiffPatch.UnitTests/NodeTests/ObjectDeepEqualsTests.cs @@ -9,7 +9,7 @@ public class ObjectDeepEqualsTests [Fact] public void Default() { - Assert.True(default(JsonNode).DeepEquals(default)); + Assert.True(default(JsonNode).DeepEquals(default, default(JsonComparerOptions))); } [Fact] @@ -26,7 +26,7 @@ public void Object_Identical() {"baz", "qux"} }; - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -43,7 +43,7 @@ public void Object_PropertyOrdering() {"foo", "bar"} }; - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -60,7 +60,7 @@ public void Object_PropertyValue() {"baz", "quz"} }; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -76,7 +76,7 @@ public void Object_MissingProperty() {"foo", "bar"} }; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -92,7 +92,7 @@ public void Object_ExtraProperty() {"baz", "qux"} }; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -101,7 +101,7 @@ public void Array_Identical() var json1 = new JsonArray {1, 2, 3}; var json2 = new JsonArray {1, 2, 3}; - Assert.True(json1.DeepEquals(json2)); + Assert.True(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -110,7 +110,7 @@ public void Array_ItemOrdering() var json1 = new JsonArray {1, 2, 3}; var json2 = new JsonArray {1, 3, 2}; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -119,7 +119,7 @@ public void Array_ItemValue() var json1 = new JsonArray {1, 2, 3}; var json2 = new JsonArray {1, 2, 5}; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -128,7 +128,7 @@ public void Array_MissingItem() var json1 = new JsonArray {1, 2, 3}; var json2 = new JsonArray {1, 2}; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Fact] @@ -137,14 +137,14 @@ public void Array_ExtraItem() var json1 = new JsonArray {1, 2}; var json2 = new JsonArray {1, 2, 3}; - Assert.False(json1.DeepEquals(json2)); + Assert.False(json1.DeepEquals(json2, default(JsonComparerOptions))); } [Theory] [MemberData(nameof(NodeTestData.ObjectSemanticEqual), MemberType = typeof(NodeTestData))] public void Value_ObjectSemanticEqual(JsonValue json1, JsonValue json2, bool expected) { - Assert.Equal(expected, json1.DeepEquals(json2)); + Assert.Equal(expected, json1.DeepEquals(json2, default(JsonComparerOptions))); } } } diff --git a/test/SystemTextJson.JsonDiffPatch.UnitTests/SystemTextJson.JsonDiffPatch.UnitTests.csproj b/test/SystemTextJson.JsonDiffPatch.UnitTests/SystemTextJson.JsonDiffPatch.UnitTests.csproj index 3a9b75e..729edcd 100644 --- a/test/SystemTextJson.JsonDiffPatch.UnitTests/SystemTextJson.JsonDiffPatch.UnitTests.csproj +++ b/test/SystemTextJson.JsonDiffPatch.UnitTests/SystemTextJson.JsonDiffPatch.UnitTests.csproj @@ -1,17 +1,13 @@  - - netcoreapp3.1;net5.0;net6.0;net461;net48 - - - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/SystemTextJson.JsonDiffPatch.Xunit.Tests/SystemTextJson.JsonDiffPatch.Xunit.Tests.csproj b/test/SystemTextJson.JsonDiffPatch.Xunit.Tests/SystemTextJson.JsonDiffPatch.Xunit.Tests.csproj index 54b9427..08aef5c 100644 --- a/test/SystemTextJson.JsonDiffPatch.Xunit.Tests/SystemTextJson.JsonDiffPatch.Xunit.Tests.csproj +++ b/test/SystemTextJson.JsonDiffPatch.Xunit.Tests/SystemTextJson.JsonDiffPatch.Xunit.Tests.csproj @@ -1,17 +1,13 @@  - - netcoreapp3.1;net5.0;net6.0;net461;net48 - - - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all