Fix TypeUtils.GetTypeName for nested generic types

This commit is contained in:
Wojtek Figat
2025-01-20 23:49:40 +01:00
parent 011abe4ac0
commit 86444aa5f3

View File

@@ -23,6 +23,33 @@ namespace FlaxEngine.Utilities
var sb = new StringBuilder();
sb.Append(type.Namespace);
sb.Append('.');
var parent = type.DeclaringType;
if (parent != null)
{
// Find outer types in which this one is nested
var count = 0;
while (parent != null)
{
count++;
parent = parent.DeclaringType;
}
var path = new Type[count];
parent = type.DeclaringType;
count = 0;
while (parent != null)
{
path[count++] = parent;
parent = parent.DeclaringType;
}
// Insert type nesting into typename path (from the back to front)
for (int i = count - 1; i >= 0; i--)
{
parent = path[i];
sb.Append(parent.Name);
sb.Append('+');
}
}
sb.Append(type.Name);
sb.Append('[');
var genericArgs = type.GetGenericArguments();