Use recursive GetGenericArguments to catch unusual type structures, cleanup InteractiveList value caching

This commit is contained in:
Sinai
2021-05-18 20:55:18 +10:00
parent 496a5de55e
commit ac9c2d5286
3 changed files with 32 additions and 15 deletions

View File

@ -36,6 +36,27 @@ namespace UnityExplorer
// ------- Misc extensions --------
/// <summary>
/// Recursively check the type and its base types to find any generic arguments.
/// </summary>
public static bool TryGetGenericArguments(this Type type, out Type[] args)
{
if (type.IsGenericType)
{
args = type.GetGenericArguments();
return true;
}
else if (type.BaseType != null)
{
return TryGetGenericArguments(type.BaseType, out args);
}
else
{
args = null;
return false;
}
}
/// <summary>
/// Safely try to get all Types inside an Assembly.
/// </summary>