From 02e83b387eff6287dcd2af4faa017c4fd71fd7a1 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Tue, 18 Jul 2023 12:08:40 -0500 Subject: [PATCH] Address feedback --- .../Text/Json/Serialization/Converters/Value/HalfConverter.cs | 4 ++-- .../System.Text.Json/tests/Common/NumberHandlingTests.cs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs index 85bb9ae2a201d..c2bee78a5fa67 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs @@ -171,13 +171,13 @@ private static void WriteFloatingPointConstant(Utf8JsonWriter writer, Half value } } - // Half.TryFormat/TryParse(ROS) are not available on .NET 7 - // we need to use Half.TryFormat/TryParse(ROS) in that case. private static bool TryParse(ReadOnlySpan buffer, out Half result) { #if NET8_0_OR_GREATER bool success = Half.TryParse(buffer, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); #else + // Half.TryFormat/TryParse(ROS) are not available on .NET 7 + // we need to use Half.TryFormat/TryParse(ROS) in that case. char[]? rentedCharBuffer = null; Span charBuffer = buffer.Length <= JsonConstants.StackallocCharThreshold diff --git a/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs b/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs index a11f47454701e..109123b92a009 100644 --- a/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs +++ b/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs @@ -1045,6 +1045,7 @@ private async Task AssertUnsupportedFormatThrows() { string[] testCases = new[] { + "01", // leading zeroes "$123.46", // Currency "100.00 %", // Percent "1234,57", // Fixed point