From 2710c1b72de24def27a94b69eaec10bd37ea7393 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 8 Jan 2023 12:30:35 +0100 Subject: [PATCH] fix(packets): make nullable, optional wrapper not throw an exception for non-generic types --- .../Converters/Common/NullableWrapperConverterFactory.cs | 2 +- .../Converters/Common/OptionalWrapperConverterFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Packets/NosSmooth.PacketSerializer/Converters/Common/NullableWrapperConverterFactory.cs b/Packets/NosSmooth.PacketSerializer/Converters/Common/NullableWrapperConverterFactory.cs index fc73c9b..e4edf62 100644 --- a/Packets/NosSmooth.PacketSerializer/Converters/Common/NullableWrapperConverterFactory.cs +++ b/Packets/NosSmooth.PacketSerializer/Converters/Common/NullableWrapperConverterFactory.cs @@ -32,7 +32,7 @@ public class NullableWrapperConverterFactory : IStringConverterFactory /// public bool ShouldHandle(Type type) - => type.GetGenericTypeDefinition() == typeof(NullableWrapper<>); + => type.IsGenericType && type.GetGenericTypeDefinition() == typeof(NullableWrapper<>); /// public Result CreateTypeSerializer(Type type) diff --git a/Packets/NosSmooth.PacketSerializer/Converters/Common/OptionalWrapperConverterFactory.cs b/Packets/NosSmooth.PacketSerializer/Converters/Common/OptionalWrapperConverterFactory.cs index 803c186..609a147 100644 --- a/Packets/NosSmooth.PacketSerializer/Converters/Common/OptionalWrapperConverterFactory.cs +++ b/Packets/NosSmooth.PacketSerializer/Converters/Common/OptionalWrapperConverterFactory.cs @@ -31,7 +31,7 @@ public class OptionalWrapperConverterFactory : IStringConverterFactory /// public bool ShouldHandle(Type type) - => type.GetGenericTypeDefinition() == typeof(OptionalWrapper<>); + => type.IsGenericType && type.GetGenericTypeDefinition() == typeof(OptionalWrapper<>); /// public Result CreateTypeSerializer(Type type) -- 2.49.0