From 7e8e04d377f95d6cc9eda87363061e10ecc1df33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:44:36 +0000 Subject: [PATCH 01/12] Initial plan for issue From 95c1bca9c11cd25c8fc4e3400e921cf7be6937bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Jun 2025 17:17:02 +0000 Subject: [PATCH 02/12] Fix buffer slicing in (U)Int128 property name serialization Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com> --- .../Text/Json/Serialization/Converters/Value/Int128Converter.cs | 2 +- .../Json/Serialization/Converters/Value/UInt128Converter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/Int128Converter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/Int128Converter.cs index 177287966db715..5f2a01836dae87 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/Int128Converter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/Int128Converter.cs @@ -73,7 +73,7 @@ internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Int128 val { Span buffer = stackalloc byte[MaxFormatLength]; Format(buffer, value, out int written); - writer.WritePropertyName(buffer); + writer.WritePropertyName(buffer.Slice(0, written)); } internal override Int128 ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt128Converter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt128Converter.cs index b66e8e47bfba37..ea5b94e9ffcbed 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt128Converter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt128Converter.cs @@ -73,7 +73,7 @@ internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, UInt128 va { Span buffer = stackalloc byte[MaxFormatLength]; Format(buffer, value, out int written); - writer.WritePropertyName(buffer); + writer.WritePropertyName(buffer.Slice(0, written)); } internal override UInt128 ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) From 5d4e9b32e5b2b3641d3490a37ab22f07d74cf754 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Jun 2025 17:21:59 +0000 Subject: [PATCH 03/12] Add regression tests for Int128/UInt128 property name serialization Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index a59e7dc9170334..a37c93796cbf80 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -187,6 +187,68 @@ public static void TimeOnly_Write_Success(string value, string? expectedValue = string json = JsonSerializer.Serialize(ts); Assert.Equal($"\"{expectedValue ?? value}\"", json); } + + [Fact] + public static void Int128_AsDictionaryKey_SerializesCorrectly() + { + // Regression test for https://github.com/dotnet/runtime/issues/116855 + // Int128Converter.WriteAsPropertyNameCore was passing unsliced buffer to WritePropertyName + var dict = new Dictionary + { + [0] = "Zero", + [1] = "One", + [-1] = "MinusOne", + [Int128.MaxValue] = "Max", + [Int128.MinValue] = "Min" + }; + + string json = JsonSerializer.Serialize(dict); + + // Should not contain null characters or other garbage data + Assert.DoesNotContain('\0', json); + Assert.DoesNotContain('\uFFFD', json); + + // Should contain proper property names + Assert.Contains("\"0\":", json); + Assert.Contains("\"1\":", json); + Assert.Contains("\"-1\":", json); + + // Should roundtrip correctly + var deserialized = JsonSerializer.Deserialize>(json); + Assert.Equal(dict.Count, deserialized.Count); + Assert.Equal("Zero", deserialized[0]); + Assert.Equal("One", deserialized[1]); + Assert.Equal("MinusOne", deserialized[-1]); + } + + [Fact] + public static void UInt128_AsDictionaryKey_SerializesCorrectly() + { + // Regression test for https://github.com/dotnet/runtime/issues/116855 + // UInt128Converter.WriteAsPropertyNameCore was passing unsliced buffer to WritePropertyName + var dict = new Dictionary + { + [0] = "Zero", + [1] = "One", + [UInt128.MaxValue] = "Max" + }; + + string json = JsonSerializer.Serialize(dict); + + // Should not contain null characters or other garbage data + Assert.DoesNotContain('\0', json); + Assert.DoesNotContain('\uFFFD', json); + + // Should contain proper property names + Assert.Contains("\"0\":", json); + Assert.Contains("\"1\":", json); + + // Should roundtrip correctly + var deserialized = JsonSerializer.Deserialize>(json); + Assert.Equal(dict.Count, deserialized.Count); + Assert.Equal("Zero", deserialized[0]); + Assert.Equal("One", deserialized[1]); + } #endif } } From debf1a4e04de67a7a09d2a96ff39cf9b10e6182d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:39:57 +0000 Subject: [PATCH 04/12] Address PR feedback: simplify test assertions and remove junk data checks Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index a37c93796cbf80..114a0b62b1301a 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -204,21 +204,9 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); - // Should not contain null characters or other garbage data - Assert.DoesNotContain('\0', json); - Assert.DoesNotContain('\uFFFD', json); - - // Should contain proper property names - Assert.Contains("\"0\":", json); - Assert.Contains("\"1\":", json); - Assert.Contains("\"-1\":", json); - // Should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); - Assert.Equal(dict.Count, deserialized.Count); - Assert.Equal("Zero", deserialized[0]); - Assert.Equal("One", deserialized[1]); - Assert.Equal("MinusOne", deserialized[-1]); + Assert.Equal(dict, deserialized); } [Fact] @@ -235,19 +223,9 @@ public static void UInt128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); - // Should not contain null characters or other garbage data - Assert.DoesNotContain('\0', json); - Assert.DoesNotContain('\uFFFD', json); - - // Should contain proper property names - Assert.Contains("\"0\":", json); - Assert.Contains("\"1\":", json); - // Should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); - Assert.Equal(dict.Count, deserialized.Count); - Assert.Equal("Zero", deserialized[0]); - Assert.Equal("One", deserialized[1]); + Assert.Equal(dict, deserialized); } #endif } From e7917eb7ca74ed801c05776c213f76997296bdd6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Jun 2025 21:11:59 +0000 Subject: [PATCH 05/12] Add JSON content validation to Int128/UInt128 dictionary tests Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 114a0b62b1301a..75ed57b6f3e39d 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -204,6 +204,14 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); + // Validate JSON content contains expected keys and no junk data + Assert.Contains("\"0\"", json); + Assert.Contains("\"1\"", json); + Assert.Contains("\"-1\"", json); + Assert.Contains("\"170141183460469231731687303715884105727\"", json); // Int128.MaxValue + Assert.Contains("\"-170141183460469231731687303715884105728\"", json); // Int128.MinValue + Assert.DoesNotContain('\0', json); // No null characters (junk data) + // Should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); @@ -223,6 +231,12 @@ public static void UInt128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); + // Validate JSON content contains expected keys and no junk data + Assert.Contains("\"0\"", json); + Assert.Contains("\"1\"", json); + Assert.Contains("\"340282366920938463463374607431768211455\"", json); // UInt128.MaxValue + Assert.DoesNotContain('\0', json); // No null characters (junk data) + // Should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); From 6bf6af5e9a5d953abc6a9cc125ccabf12de3bb0d Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Mon, 23 Jun 2025 16:26:30 +0300 Subject: [PATCH 06/12] Update src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs --- .../System.Text.Json.Tests/Serialization/Value.WriteTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 75ed57b6f3e39d..7a32e976a9fa9c 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -221,7 +221,6 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() public static void UInt128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 - // UInt128Converter.WriteAsPropertyNameCore was passing unsliced buffer to WritePropertyName var dict = new Dictionary { [0] = "Zero", From c219e4ca76b1129e03ac010cd86a352c1f4147b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:39:57 +0000 Subject: [PATCH 07/12] Replace multiple assertions with single E2E validation in Int128 dictionary test Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 7a32e976a9fa9c..ee66fd32519ab3 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -204,15 +204,7 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); - // Validate JSON content contains expected keys and no junk data - Assert.Contains("\"0\"", json); - Assert.Contains("\"1\"", json); - Assert.Contains("\"-1\"", json); - Assert.Contains("\"170141183460469231731687303715884105727\"", json); // Int128.MaxValue - Assert.Contains("\"-170141183460469231731687303715884105728\"", json); // Int128.MinValue - Assert.DoesNotContain('\0', json); // No null characters (junk data) - - // Should roundtrip correctly + // E2E validation: should roundtrip correctly without any junk data var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); } From f40d2272dbccd876e91f0938470a9e319ca217ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:06:04 +0000 Subject: [PATCH 08/12] Address PR feedback: remove implementation details and add JSON content validation Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index ee66fd32519ab3..8c21b905ad7a97 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -192,7 +192,6 @@ public static void TimeOnly_Write_Success(string value, string? expectedValue = public static void Int128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 - // Int128Converter.WriteAsPropertyNameCore was passing unsliced buffer to WritePropertyName var dict = new Dictionary { [0] = "Zero", @@ -204,6 +203,14 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); + // Validate JSON content contains expected keys and no junk data + Assert.Contains("\"0\"", json); + Assert.Contains("\"1\"", json); + Assert.Contains("\"-1\"", json); + Assert.Contains("\"170141183460469231731687303715884105727\"", json); // Int128.MaxValue + Assert.Contains("\"-170141183460469231731687303715884105728\"", json); // Int128.MinValue + Assert.DoesNotContain('\0', json); // No null characters (junk data) + // E2E validation: should roundtrip correctly without any junk data var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); From 13609194c5219fd29e4084bff2b0b009b10e01fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:45:15 +0000 Subject: [PATCH 09/12] Replace Assert.Contains with Assert.Equal for E2E JSON validation in Int128/UInt128 tests Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 8c21b905ad7a97..5b440c9a725f46 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -192,26 +192,18 @@ public static void TimeOnly_Write_Success(string value, string? expectedValue = public static void Int128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 + // Test with a single key to ensure deterministic output for Assert.Equal var dict = new Dictionary { - [0] = "Zero", - [1] = "One", - [-1] = "MinusOne", - [Int128.MaxValue] = "Max", - [Int128.MinValue] = "Min" + [42] = "Answer" }; string json = JsonSerializer.Serialize(dict); - // Validate JSON content contains expected keys and no junk data - Assert.Contains("\"0\"", json); - Assert.Contains("\"1\"", json); - Assert.Contains("\"-1\"", json); - Assert.Contains("\"170141183460469231731687303715884105727\"", json); // Int128.MaxValue - Assert.Contains("\"-170141183460469231731687303715884105728\"", json); // Int128.MinValue - Assert.DoesNotContain('\0', json); // No null characters (junk data) + // Verify the exact JSON output - should be clean without junk data + Assert.Equal("{\"42\":\"Answer\"}", json); - // E2E validation: should roundtrip correctly without any junk data + // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); } @@ -220,22 +212,18 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() public static void UInt128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 + // Test with a single key to ensure deterministic output for Assert.Equal var dict = new Dictionary { - [0] = "Zero", - [1] = "One", - [UInt128.MaxValue] = "Max" + [42] = "Answer" }; string json = JsonSerializer.Serialize(dict); - // Validate JSON content contains expected keys and no junk data - Assert.Contains("\"0\"", json); - Assert.Contains("\"1\"", json); - Assert.Contains("\"340282366920938463463374607431768211455\"", json); // UInt128.MaxValue - Assert.DoesNotContain('\0', json); // No null characters (junk data) + // Verify the exact JSON output - should be clean without junk data + Assert.Equal("{\"42\":\"Answer\"}", json); - // Should roundtrip correctly + // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); } From 305efb8d4d25783446b42d9ea03fa5bb8cbe9675 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:38:02 +0000 Subject: [PATCH 10/12] Restore multi-key dictionaries in Int128/UInt128 tests as requested Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 5b440c9a725f46..28b47b8bcc91f0 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -192,16 +192,19 @@ public static void TimeOnly_Write_Success(string value, string? expectedValue = public static void Int128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 - // Test with a single key to ensure deterministic output for Assert.Equal var dict = new Dictionary { - [42] = "Answer" + [0] = "Zero", + [1] = "One", + [-1] = "MinusOne", + [Int128.MaxValue] = "Max", + [Int128.MinValue] = "Min" }; string json = JsonSerializer.Serialize(dict); // Verify the exact JSON output - should be clean without junk data - Assert.Equal("{\"42\":\"Answer\"}", json); + Assert.Equal("{\"0\":\"Zero\",\"1\":\"One\",\"-1\":\"MinusOne\",\"170141183460469231731687303715884105727\":\"Max\",\"-170141183460469231731687303715884105728\":\"Min\"}", json); // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); @@ -212,16 +215,17 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() public static void UInt128_AsDictionaryKey_SerializesCorrectly() { // Regression test for https://github.com/dotnet/runtime/issues/116855 - // Test with a single key to ensure deterministic output for Assert.Equal var dict = new Dictionary { - [42] = "Answer" + [0] = "Zero", + [1] = "One", + [UInt128.MaxValue] = "Max" }; string json = JsonSerializer.Serialize(dict); // Verify the exact JSON output - should be clean without junk data - Assert.Equal("{\"42\":\"Answer\"}", json); + Assert.Equal("{\"0\":\"Zero\",\"1\":\"One\",\"340282366920938463463374607431768211455\":\"Max\"}", json); // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); From 9bdc465712288889f202daaffba7abd1973289eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 16:46:17 +0000 Subject: [PATCH 11/12] Use raw string literals for JSON assertions in Int128/UInt128 tests Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../System.Text.Json.Tests/Serialization/Value.WriteTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index 28b47b8bcc91f0..cf8dbef8d2d3f0 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -204,7 +204,7 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); // Verify the exact JSON output - should be clean without junk data - Assert.Equal("{\"0\":\"Zero\",\"1\":\"One\",\"-1\":\"MinusOne\",\"170141183460469231731687303715884105727\":\"Max\",\"-170141183460469231731687303715884105728\":\"Min\"}", json); + Assert.Equal("""{"0":"Zero","1":"One","-1":"MinusOne","170141183460469231731687303715884105727":"Max","-170141183460469231731687303715884105728":"Min"}""", json); // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); @@ -225,7 +225,7 @@ public static void UInt128_AsDictionaryKey_SerializesCorrectly() string json = JsonSerializer.Serialize(dict); // Verify the exact JSON output - should be clean without junk data - Assert.Equal("{\"0\":\"Zero\",\"1\":\"One\",\"340282366920938463463374607431768211455\":\"Max\"}", json); + Assert.Equal("""{"0":"Zero","1":"One","340282366920938463463374607431768211455":"Max"}""", json); // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); From 0422d1b77c207c25e4a1c2ec4e19e0aac362ac54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:10:56 +0000 Subject: [PATCH 12/12] Remove superficial comments from Int128/UInt128 dictionary tests Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> --- .../Serialization/Value.WriteTests.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs index cf8dbef8d2d3f0..f45410a76ea3a5 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Value.WriteTests.cs @@ -202,11 +202,8 @@ public static void Int128_AsDictionaryKey_SerializesCorrectly() }; string json = JsonSerializer.Serialize(dict); - - // Verify the exact JSON output - should be clean without junk data Assert.Equal("""{"0":"Zero","1":"One","-1":"MinusOne","170141183460469231731687303715884105727":"Max","-170141183460469231731687303715884105728":"Min"}""", json); - // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); } @@ -223,11 +220,8 @@ public static void UInt128_AsDictionaryKey_SerializesCorrectly() }; string json = JsonSerializer.Serialize(dict); - - // Verify the exact JSON output - should be clean without junk data Assert.Equal("""{"0":"Zero","1":"One","340282366920938463463374607431768211455":"Max"}""", json); - // E2E validation: should roundtrip correctly var deserialized = JsonSerializer.Deserialize>(json); Assert.Equal(dict, deserialized); }