From 11a84545c438d5fd9bb4c82d9aad1c551c483fd6 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 14 Jul 2026 17:19:05 +0100 Subject: [PATCH] Remove dead net9 code --- .../src/System.Text.Json.csproj | 2 +- .../Text/Json/Nodes/JsonObject.IDictionary.cs | 5 ---- .../src/System/Text/Json/Nodes/JsonObject.cs | 23 +------------------ 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj index 0a80a0e73974c8..ede6ef9a4172c3 100644 --- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj +++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj @@ -392,7 +392,7 @@ The System.Text.Json library is built-in as part of the shared framework in .NET - + diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.IDictionary.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.IDictionary.cs index a16888ed3ecbb1..4d73bb3021e88c 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.IDictionary.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.IDictionary.cs @@ -58,12 +58,7 @@ public bool TryAdd(string propertyName, JsonNode? value, out int index) { ThrowHelper.ThrowArgumentNullException(nameof(propertyName)); } -#if NET9_0 - bool success = Dictionary.TryAdd(propertyName, value); - index = success ? Dictionary.Count - 1 : Dictionary.IndexOf(propertyName); -#else bool success = Dictionary.TryAdd(propertyName, value, out index); -#endif if (success) { value?.AssignParent(this); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs index 5ded130cff70ca..07fac1d7ca2550 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs @@ -142,19 +142,7 @@ public bool TryGetPropertyValue(string propertyName, out JsonNode? jsonNode, out { ArgumentNullException.ThrowIfNull(propertyName); -#if NET9_0 - index = Dictionary.IndexOf(propertyName); - if (index < 0) - { - jsonNode = null; - return false; - } - - jsonNode = Dictionary.GetAt(index).Value; - return true; -#else return Dictionary.TryGetValue(propertyName, out jsonNode, out index); -#endif } /// @@ -287,17 +275,8 @@ internal void SetItem(string propertyName, JsonNode? value) OrderedDictionary dict = Dictionary; - if ( -#if NET9_0 - !dict.TryAdd(propertyName, value) -#else - !dict.TryAdd(propertyName, value, out int index) -#endif - ) + if (!dict.TryAdd(propertyName, value, out int index)) { -#if NET9_0 - int index = dict.IndexOf(propertyName); -#endif Debug.Assert(index >= 0); JsonNode? replacedValue = dict.GetAt(index).Value;