Implement and output TypeInfo.BaseType

This commit is contained in:
Katy Coe
2017-11-09 13:21:53 +01:00
parent ff37a7ddeb
commit 1564ead89d
2 changed files with 12 additions and 2 deletions

View File

@@ -36,7 +36,11 @@ namespace Il2CppInspector
writer.Write("interface ");
else
writer.Write("class ");
writer.Write($"{type.Name} // TypeDefIndex: {type.Index}\n{{\n");
var baseText = type.BaseType?.CSharpName ?? "object";
baseText = baseText == "object" ? string.Empty : " : " + baseText;
writer.Write($"{type.Name}{baseText} // TypeDefIndex: {type.Index}\n{{\n");
if (type.DeclaredFields.Count > 0)
writer.Write("\t// Fields\n");
@@ -56,6 +60,8 @@ namespace Il2CppInspector
writer.Write($" = {field.DefaultValueString}");
writer.Write("; // 0x{0:X}\n", field.Offset);
}
if (type.DeclaredFields.Count > 0)
writer.Write("\n");
if (type.DeclaredMethods.Count > 0)
writer.Write("\t// Methods\n");

View File

@@ -21,7 +21,8 @@ namespace Il2CppInspector.Reflection {
public TypeAttributes Attributes { get; }
// Type that this type inherits from
public TypeInfo BaseType => throw new NotImplementedException();
private Il2CppType baseType;
public TypeInfo BaseType => baseType != null? Assembly.Model.GetType(baseType, MemberTypes.TypeInfo) : null;
// True if the type contains unresolved generic type parameters
public bool ContainsGenericParameters { get; }
@@ -121,6 +122,9 @@ namespace Il2CppInspector.Reflection {
Namespace = pkg.Strings[Definition.namespaceIndex];
Name = pkg.Strings[pkg.TypeDefinitions[typeIndex].nameIndex];
if (Definition.parentIndex >= 0)
baseType = pkg.TypeUsages[Definition.parentIndex];
if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_SERIALIZABLE) != 0)
Attributes |= TypeAttributes.Serializable;
if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_VISIBILITY_MASK) == Il2CppConstants.TYPE_ATTRIBUTE_PUBLIC)