From b122f7106c8fc238a9d1f07092bfa4dd2884ad31 Mon Sep 17 00:00:00 2001 From: Archangel Date: Mon, 17 Feb 2025 15:14:07 +0100 Subject: [PATCH] Handle check in if statement --- .../Json/Converters/StringToNumberFactoryConverter.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Utils/Json/Converters/StringToNumberFactoryConverter.cs b/Libraries/Core/Utils/Json/Converters/StringToNumberFactoryConverter.cs index 7bde0ab8..eca9d2e0 100644 --- a/Libraries/Core/Utils/Json/Converters/StringToNumberFactoryConverter.cs +++ b/Libraries/Core/Utils/Json/Converters/StringToNumberFactoryConverter.cs @@ -24,8 +24,11 @@ public class StringToNumberFactoryConverter : JsonConverterFactory static StringToNumberConverter() { // Do reflection only once to get parse - var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); - stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string)]); + if (stringParseMethod == null) + { + var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); + stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string)]); + } } public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)