diff --git a/src/AppMotor.Core/Extensions/TypeExtensions.cs b/src/AppMotor.Core/Extensions/TypeExtensions.cs index 9cb05bc5..ad7dfac5 100644 --- a/src/AppMotor.Core/Extensions/TypeExtensions.cs +++ b/src/AppMotor.Core/Extensions/TypeExtensions.cs @@ -316,7 +316,7 @@ public static bool Is(this Type typeToCheck, Type baseOrInterfaceType) // if (baseOrInterfaceType.IsInterface) { - var baseTypeFullName = baseOrInterfaceType.FullName!; + var interfaceTypeFullName = baseOrInterfaceType.FullName!; // // Try "Type.GetInterface()" first, if possible. @@ -326,7 +326,7 @@ public static bool Is(this Type typeToCheck, Type baseOrInterfaceType) { try { - var implementedInterface = typeToCheck.GetInterface(baseTypeFullName); + var implementedInterface = typeToCheck.GetInterface(interfaceTypeFullName); return implementedInterface?.Assembly == baseOrInterfaceType.Assembly; } catch (AmbiguousMatchException) diff --git a/tests/AppMotor.Core.Tests/Tests/Extensions/TypeExtensionsTests.cs b/tests/AppMotor.Core.Tests/Tests/Extensions/TypeExtensionsTests.cs index 5a506dc6..0c08c70a 100644 --- a/tests/AppMotor.Core.Tests/Tests/Extensions/TypeExtensionsTests.cs +++ b/tests/AppMotor.Core.Tests/Tests/Extensions/TypeExtensionsTests.cs @@ -184,6 +184,7 @@ public void Test_Is() [Fact] public void Test_Is_OpenGeneric() { + // Non-nested types typeof(List).Is(typeof(IReadOnlyCollection<>)).ShouldBe(true); typeof(List<>).Is(typeof(IReadOnlyCollection<>)).ShouldBe(true); typeof(List<>).Is(typeof(IReadOnlyCollection)).ShouldBe(false); @@ -191,6 +192,7 @@ public void Test_Is_OpenGeneric() typeof(List<>).Is(typeof(int)).ShouldBe(false); typeof(List).Is(typeof(GenericClassA<>)).ShouldBe(false); + // Nested types typeof(GenericClassB).Is(typeof(IGenericTestInterface<>)).ShouldBe(true); typeof(GenericClassB).Is(typeof(GenericClassA<>)).ShouldBe(true); typeof(GenericClassC).Is(typeof(GenericClassA<>)).ShouldBe(true);