From 80afab8374316c368deb24c74c9db2fc8ec2d4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Fri, 7 Jan 2022 16:03:01 +0100 Subject: [PATCH] fix: remove TUnderlyingType constraint in enum string converter --- .../Converters/Special/Converters/EnumStringConverter.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Core/NosSmooth.Packets/Converters/Special/Converters/EnumStringConverter.cs b/Core/NosSmooth.Packets/Converters/Special/Converters/EnumStringConverter.cs index 125f16cc84a99a4b92ac7d80313e9487a7b1d027..48a1291b5637da28208a7596220d76b51ecc74be 100644 --- a/Core/NosSmooth.Packets/Converters/Special/Converters/EnumStringConverter.cs +++ b/Core/NosSmooth.Packets/Converters/Special/Converters/EnumStringConverter.cs @@ -15,7 +15,6 @@ namespace NosSmooth.Packets.Converters.Special.Converters; /// The enum. /// The enum's underlying type. public class EnumStringConverter : BaseStringConverter - where TEnum : TUnderlyingType { private readonly IStringSerializer _serializer; @@ -31,7 +30,7 @@ public class EnumStringConverter : BaseStringConverter public override Result Serialize(TEnum? obj, PacketStringBuilder builder) { - builder.Append(((TUnderlyingType?)obj)?.ToString() ?? "-"); + builder.Append(((TUnderlyingType?)(object?)obj)?.ToString() ?? "-"); return Result.FromSuccess(); } @@ -44,6 +43,6 @@ public class EnumStringConverter : BaseStringConverter.FromError(result); } - return (TEnum?)result.Entity; + return (TEnum?)(object?)result.Entity; } } \ No newline at end of file