diff --git a/src/Helpers/EnumHelpers.cs b/src/Helpers/EnumHelpers.cs index ab410778..d98cc3da 100644 --- a/src/Helpers/EnumHelpers.cs +++ b/src/Helpers/EnumHelpers.cs @@ -27,7 +27,6 @@ public static class EnumHelpers { if(string.IsNullOrEmpty(rawValue)) return null; - var type = typeof(T); rawValue = ToEnumRawName(rawValue!); if(typeof(T).IsDefined(typeof(FlagsAttribute))) { @@ -58,12 +57,7 @@ public static class EnumHelpers private static string ToEnumRawName(string value) where T : struct, Enum #endif { - if(TryGetFieldValueName(typeof(T), value, out var val)) - { - value = val; - } - - return value; + return TryGetFieldValueName(typeof(T), value, out var val) ? val : value; } #if NET5_0_OR_GREATER @@ -72,13 +66,7 @@ private static string ToEnumRawName(string value) where T : struct, Enum private static ReadOnlySpan ToEnumRawName(ReadOnlySpan span) where T : struct, Enum #endif { - var value = span.ToString(); - if(TryGetFieldValueName(typeof(T), value, out var val)) - { - value = val; - } - - return value.AsSpan(); + return TryGetFieldValueName(typeof(T), span.ToString(), out var val) ? val.AsSpan() : span; } ///