From a44c0eecf099b8aa6a119fc2d4abd9a904b4f700 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Sat, 14 Aug 2021 12:45:24 +0100 Subject: [PATCH] reproduce nullable boxing issue; to be run using the benchmark added in https://github.com/dotnet/performance/pull/1920 --- .../Json/Serialization/Converters/Value/NullableConverter.cs | 2 -- .../src/System/Text/Json/Serialization/JsonConverterOfT.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverter.cs index 227a8c32a9f42..ba69c3efbf9ff 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverter.cs @@ -70,7 +70,5 @@ internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, T? v _converter.WriteNumberWithCustomHandling(writer, value.Value, handling); } } - - internal override bool IsNull(in T? value) => !value.HasValue; } } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs index d34b8e06db3b8..22866903cfd28 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs @@ -312,7 +312,7 @@ internal override sealed bool TryReadAsObject(ref Utf8JsonReader reader, JsonSer /// /// Overridden by the nullable converter to prevent boxing of values by the JIT. /// - internal virtual bool IsNull(in T value) => value == null; + private bool IsNull(in T value) => value == null; internal bool TryWrite(Utf8JsonWriter writer, in T value, JsonSerializerOptions options, ref WriteStack state) {