Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/ModularPipelines/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,28 @@ internal static class TypeExtensions
{
public static bool IsOrInheritsFrom(this Type type, Type otherType)
{
return type == otherType || type.IsSubclassOf(otherType);
if (type == otherType)
{
return true;
}

if (!otherType.IsGenericType)
{
return type.IsSubclassOf(otherType);
}

var baseType = type.BaseType;
while (baseType is not null)
{
if (baseType.IsGenericType && baseType.GetGenericTypeDefinition() == otherType)
{
return true;
}

baseType = baseType.BaseType;
}

return false;
}

public static string GetRealTypeName(this Type type)
Expand Down