AppModel/C++: Unused concrete value types were not included

This commit is contained in:
Katy Coe
2020-09-05 11:42:58 +02:00
parent ed91f2a3e0
commit fd4e61bacd
2 changed files with 12 additions and 0 deletions

View File

@@ -252,6 +252,17 @@ namespace Il2CppInspector.Model
} }
} }
// Find unused concrete value types
var usedTypes = Types.Values.Select(t => t.Type);
var unusedTypes = TypeModel.Types.Except(usedTypes);
var unusedValueTypes = unusedTypes.Where(t => t.IsValueType && !t.IsGenericType && !t.IsGenericParameter);
Group = "unused_value_types";
foreach (var type in unusedValueTypes)
declarationGenerator.IncludeType(type);
AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations());
// Restore stdout // Restore stdout
Console.SetOut(stdout); Console.SetOut(stdout);

View File

@@ -72,6 +72,7 @@ typedef size_t uintptr_t;
writeTypesForGroup("Application types from method calls", "types_from_methods"); writeTypesForGroup("Application types from method calls", "types_from_methods");
writeTypesForGroup("Application types from generic methods", "types_from_generic_methods"); writeTypesForGroup("Application types from generic methods", "types_from_generic_methods");
writeTypesForGroup("Application types from usages", "types_from_usages"); writeTypesForGroup("Application types from usages", "types_from_usages");
writeTypesForGroup("Application unused value types", "unused_value_types");
writeCode("#if !defined(_GHIDRA_) && !defined(_IDA_)"); writeCode("#if !defined(_GHIDRA_) && !defined(_IDA_)");
writeCode("}"); writeCode("}");