From 85ab34f5696479ae6e547b9c8b96b638ca96f621 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 21 Sep 2020 20:56:19 +0200 Subject: [PATCH] C++: Include unused concrete types in scaffolding output (#71) --- Il2CppInspector.Common/Model/AppModel.cs | 7 ++++--- Il2CppInspector.Common/Outputs/CppScaffolding.cs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index dc70fe9..93e1efe 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -255,11 +255,12 @@ 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); + var unusedConcreteTypes = unusedTypes.Where(t => !t.IsGenericType && !t.IsGenericParameter + && !t.IsByRef && !t.IsPointer && !t.IsArray && !t.IsAbstract && t.Name != ""); - Group = "unused_value_types"; + Group = "unused_concrete_types"; - foreach (var type in unusedValueTypes) + foreach (var type in unusedConcreteTypes) declarationGenerator.IncludeType(type); AddTypes(declarationGenerator.GenerateRemainingTypeDeclarations()); diff --git a/Il2CppInspector.Common/Outputs/CppScaffolding.cs b/Il2CppInspector.Common/Outputs/CppScaffolding.cs index 34b1c58..5270977 100644 --- a/Il2CppInspector.Common/Outputs/CppScaffolding.cs +++ b/Il2CppInspector.Common/Outputs/CppScaffolding.cs @@ -81,7 +81,7 @@ typedef size_t uintptr_t; writeTypesForGroup("Application types from method calls", "types_from_methods"); writeTypesForGroup("Application types from generic methods", "types_from_generic_methods"); writeTypesForGroup("Application types from usages", "types_from_usages"); - writeTypesForGroup("Application unused value types", "unused_value_types"); + writeTypesForGroup("Application unused value types", "unused_concrete_types"); writeCode("#if !defined(_GHIDRA_) && !defined(_IDA_)"); writeCode("}");