diff --git a/Assets/BetterExtensions/Runtime/Extensions/TypeExtensions.cs b/Assets/BetterExtensions/Runtime/Extensions/TypeExtensions.cs index 0b65479..0f83442 100644 --- a/Assets/BetterExtensions/Runtime/Extensions/TypeExtensions.cs +++ b/Assets/BetterExtensions/Runtime/Extensions/TypeExtensions.cs @@ -41,7 +41,41 @@ public static bool IsEnumerable(this Type self) } var enumerableType = typeof(IEnumerable<>); - return self.IsSubclassOfRawGeneric(enumerableType); + return enumerableType.IsAssignableFromRawGeneric(self); + } + + public static bool IsAssignableFromRawGeneric(this Type self, Type type) + { + if (self == null) + { + DebugUtility.LogException(nameof(self)); + return false; + } + + if (type == null) + { + DebugUtility.LogException(nameof(type)); + return false; + } + + var bufferType = type; + while (bufferType.BaseType != null) + { + if (bufferType.IsGeneric(self)) + { + return true; + } + + foreach (var subType in bufferType.GetInterfaces()) + { + if (!subType.IsGeneric(self)) continue; + return true; + } + + bufferType = bufferType.BaseType; + } + + return false; } public static bool IsGeneric(this Type self, Type type) diff --git a/Assets/BetterExtensions/package.json b/Assets/BetterExtensions/package.json index 78a65dc..6612a6d 100644 --- a/Assets/BetterExtensions/package.json +++ b/Assets/BetterExtensions/package.json @@ -1,7 +1,7 @@ { "name": "com.uurha.betterextensions", "displayName": "Better Extensions", - "version": "1.5.9", + "version": "1.5.91", "unity": "2021.3", "description": "Unity extensions, serialize extension, async extension, string extension and UI extensions", "dependencies": {