From d1e67cbc5dbd2d6a46be4246e6c53c3dcf93244f Mon Sep 17 00:00:00 2001 From: Antoine Griffard Date: Sun, 31 Mar 2024 11:39:12 +0200 Subject: [PATCH 1/2] mkdocs-material 9.5.16 --- src/docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/requirements.txt b/src/docs/requirements.txt index 1ec8f2c22c9..d4f3670c571 100644 --- a/src/docs/requirements.txt +++ b/src/docs/requirements.txt @@ -1,5 +1,5 @@ mkdocs>=1.5.3 -mkdocs-material>=9.5.15 +mkdocs-material>=9.5.16 mkdocs-git-authors-plugin>=0.8.0 mkdocs-git-revision-date-localized-plugin>=1.2.4 pymdown-extensions>=10.7.1 From 549ae43f67761dfb03fcaaf5eed0a61868c8f7de Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Sun, 31 Mar 2024 19:30:12 +0300 Subject: [PATCH 2/2] Remove unnecessary null coalescing in settings.MergeArrayHandling (#15599) --- .../Json/Nodes/JArray.cs | 2 +- .../OrchardCore.Abstractions.csproj | 1 + .../Abstractions/Json/Nodes/JArrayTests.cs | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/OrchardCore.Tests/Abstractions/Json/Nodes/JArrayTests.cs diff --git a/src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JArray.cs b/src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JArray.cs index 828b9503892..b354a393311 100644 --- a/src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JArray.cs +++ b/src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JArray.cs @@ -118,7 +118,7 @@ public static bool ContainsValue(this JsonArray? jsonArray, JsonValue? value) settings ??= new JsonMergeSettings(); - switch (settings?.MergeArrayHandling ?? MergeArrayHandling.Concat) + switch (settings.MergeArrayHandling) { case MergeArrayHandling.Concat: diff --git a/src/OrchardCore/OrchardCore.Abstractions/OrchardCore.Abstractions.csproj b/src/OrchardCore/OrchardCore.Abstractions/OrchardCore.Abstractions.csproj index c39dcada174..3f580b270c1 100644 --- a/src/OrchardCore/OrchardCore.Abstractions/OrchardCore.Abstractions.csproj +++ b/src/OrchardCore/OrchardCore.Abstractions/OrchardCore.Abstractions.csproj @@ -12,6 +12,7 @@ + diff --git a/test/OrchardCore.Tests/Abstractions/Json/Nodes/JArrayTests.cs b/test/OrchardCore.Tests/Abstractions/Json/Nodes/JArrayTests.cs new file mode 100644 index 00000000000..740d12441bc --- /dev/null +++ b/test/OrchardCore.Tests/Abstractions/Json/Nodes/JArrayTests.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Nodes; +using System.Text.Json.Settings; + +namespace OrchardCore.Json.Nodes.Test; + +public class JArrayTests +{ + public static IEnumerable MergeArrayEntries => [ + ["[1, 2, 3, 4]", "[4, 5, 6]", null, "[1,2,3,4,4,5,6]"], + ["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Concat }, "[1,2,3,4,4,5,6]"], + ["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Union }, "[1,2,3,4,5,6]"], + ["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Replace }, "[4,5,6]"] + ]; + + [Theory] + [MemberData(nameof(MergeArrayEntries))] + public void MergeArrayShouldRespectJsonMergeSettings(string jsonArrayContent1, string jsonArrayContent2, JsonMergeSettings mergeSettings, string expectedJsonString) + { + // Arrange + var array = JsonNode.Parse(jsonArrayContent1) as JsonArray; + var content = JsonNode.Parse(jsonArrayContent2); + + // Act + var result = array.Merge(content, mergeSettings); + + // Assert + Assert.NotNull(result); + Assert.Equal(expectedJsonString, result.ToJsonString()); + } +}