simplify custom attribute logic a bit by always returning arrays as ConstantBlobArrayElement

This commit is contained in:
LukeFZ
2023-12-01 06:46:58 +01:00
parent 6aa96b431d
commit 227aefedef
5 changed files with 19 additions and 38 deletions

View File

@@ -75,10 +75,6 @@ namespace Il2CppInspector.Reflection
foreach (var info in GetTypeReferences(array))
yield return info;
break;
case TypeInfo[] infos:
foreach (var info in infos)
yield return info;
break;
}
}
}

View File

@@ -209,7 +209,7 @@ namespace Il2CppInspector.Reflection
}
case TypeInfo typeInfo:
return $"typeof({typeInfo.GetScopedCSharpName(usingScope)})";
case object[] array:
case CustomAttributeArgument[] array:
var arraySb = new StringBuilder();
arraySb.Append("new ");
arraySb.Append(type.GetScopedCSharpName(usingScope));
@@ -222,8 +222,7 @@ namespace Il2CppInspector.Reflection
arraySb.Append(" {");
for (int i = 0; i < array.Length; i++)
{
if (array[i] is CustomAttributeArgument arrayArgument) // Used for array with different entries, see BlobReader for more info
arraySb.Append(arrayArgument.Value.ToCSharpValue(arrayArgument.Type, usingScope));
arraySb.Append(array[i].Value.ToCSharpValue(array[i].Type, usingScope));
if (i + 1 != array.Length)
arraySb.Append(", ");