Output struct declarations correctly

This commit is contained in:
Katy Coe
2017-11-09 13:59:33 +01:00
parent 1564ead89d
commit 3722705301
2 changed files with 6 additions and 4 deletions

View File

@@ -30,15 +30,17 @@ namespace Il2CppInspector
writer.Write("public ");
if (type.IsAbstract)
writer.Write("abstract ");
if (type.IsSealed)
if (type.IsSealed && !type.IsValueType)
writer.Write("sealed ");
if (type.IsInterface)
writer.Write("interface ");
else if (type.IsValueType)
writer.Write("struct ");
else
writer.Write("class ");
var baseText = type.BaseType?.CSharpName ?? "object";
baseText = baseText == "object" ? string.Empty : " : " + baseText;
var baseText = type.BaseType?.CSharpName ?? string.Empty;
baseText = (baseText == "object" || baseText == "ValueType" || baseText == string.Empty)? string.Empty : " : " + baseText;
writer.Write($"{type.Name}{baseText} // TypeDefIndex: {type.Index}\n{{\n");

View File

@@ -84,7 +84,7 @@ namespace Il2CppInspector.Reflection {
public bool IsPublic => (Attributes & TypeAttributes.Public) == TypeAttributes.Public;
public bool IsSealed => (Attributes & TypeAttributes.Sealed) == TypeAttributes.Sealed;
public bool IsSerializable => (Attributes & TypeAttributes.Serializable) == TypeAttributes.Serializable;
public bool IsValueType => throw new NotImplementedException();
public bool IsValueType => BaseType?.FullName == "System.ValueType";
public override MemberTypes MemberType { get; }