From d05b4a28f132a4fa78cee35f386fec07139b627d Mon Sep 17 00:00:00 2001 From: Chris Winland Date: Tue, 31 May 2022 09:36:05 -0400 Subject: [PATCH] Replace IsNullableType for compatibility --- FastMoq/Mocks.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FastMoq/Mocks.cs b/FastMoq/Mocks.cs index 86441f6..5afacdc 100644 --- a/FastMoq/Mocks.cs +++ b/FastMoq/Mocks.cs @@ -490,13 +490,14 @@ internal static bool IsValidConstructor(ConstructorInfo info, params object?[] i { var paramType = paramList[i].ParameterType; var instanceType = instanceParameterValues[i]?.GetType(); - isValid &= (instanceType == null && paramType.IsNullableType()) || (instanceType != null && paramType.IsAssignableFrom(instanceType)); + isValid &= (instanceType == null && IsNullableType(paramType)) || (instanceType != null && paramType.IsAssignableFrom(instanceType)); } return isValid; } + internal static bool IsNullableType(Type type) => type.IsGenericType && type.GetGenericTypeDefinition() == typeof (Nullable<>); internal static bool IsMockFileSystem(bool usePredefinedFileSystem) => usePredefinedFileSystem && (typeof(T) == typeof(IFileSystem) || typeof(T) == typeof(FileSystem)); internal static void ThrowAlreadyExists(Type type) => throw new ArgumentException($"{type} already exists."); }