From 95d88e60d76ff4decddf9144de0db5089306a535 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 15 Aug 2020 02:34:19 +0200 Subject: [PATCH] AppModel: Build model by default in constructor --- Il2CppInspector.CLI/Program.cs | 2 +- Il2CppInspector.Common/Model/AppModel.cs | 6 +++++- Il2CppInspector.GUI/App.xaml.cs | 2 +- Il2CppTests/TestAppModelQueries.cs | 2 +- Il2CppTests/TestRunner.cs | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Il2CppInspector.CLI/Program.cs b/Il2CppInspector.CLI/Program.cs index 8e3507a..38191ba 100644 --- a/Il2CppInspector.CLI/Program.cs +++ b/Il2CppInspector.CLI/Program.cs @@ -213,7 +213,7 @@ namespace Il2CppInspector.CLI AppModel appModel; using (new Benchmark("Create C++ application model")) { - appModel = new AppModel(model).Build(options.UnityVersion, options.CppCompiler); + appModel = new AppModel(model, makeDefaultBuild: false).Build(options.UnityVersion, options.CppCompiler); } // C# signatures output diff --git a/Il2CppInspector.Common/Model/AppModel.cs b/Il2CppInspector.Common/Model/AppModel.cs index a98a962..51e23a7 100644 --- a/Il2CppInspector.Common/Model/AppModel.cs +++ b/Il2CppInspector.Common/Model/AppModel.cs @@ -97,7 +97,7 @@ namespace Il2CppInspector.Model } // Initialize - public AppModel(TypeModel model) { + public AppModel(TypeModel model, bool makeDefaultBuild = true) { // Save .NET type model TypeModel = model; @@ -106,6 +106,10 @@ namespace Il2CppInspector.Model // Get all symbols Symbols = Image.GetSymbolTable(); + + // Build if requested + if (makeDefaultBuild) + Build(); } // Build the application model targeting a specific version of Unity and C++ compiler diff --git a/Il2CppInspector.GUI/App.xaml.cs b/Il2CppInspector.GUI/App.xaml.cs index d78ffda..325b3c4 100644 --- a/Il2CppInspector.GUI/App.xaml.cs +++ b/Il2CppInspector.GUI/App.xaml.cs @@ -104,7 +104,7 @@ namespace Il2CppInspectorGUI // Initialize (but don't build) application model // We will build the model after the user confirms the Unity version and target compiler - AppModels.Add(new AppModel(typeModel)); + AppModels.Add(new AppModel(typeModel, makeDefaultBuild: false)); } } // Unsupported architecture; ignore it diff --git a/Il2CppTests/TestAppModelQueries.cs b/Il2CppTests/TestAppModelQueries.cs index 7d3750f..e445ccc 100644 --- a/Il2CppTests/TestAppModelQueries.cs +++ b/Il2CppTests/TestAppModelQueries.cs @@ -29,7 +29,7 @@ namespace Il2CppInspector // Act var inspectors = Il2CppInspector.LoadFromFile(testPath + @"\ArraysAndPointers-ARM64.so", testPath + @"\global-metadata.dat"); var model = new TypeModel(inspectors[0]); - var app = new AppModel(model).Build(); + var app = new AppModel(model); // Assert diff --git a/Il2CppTests/TestRunner.cs b/Il2CppTests/TestRunner.cs index 63151d4..cbc9b99 100644 --- a/Il2CppTests/TestRunner.cs +++ b/Il2CppTests/TestRunner.cs @@ -45,7 +45,7 @@ namespace Il2CppInspector int i = 0; foreach (var il2cpp in inspectors) { var model = new TypeModel(il2cpp); - var appModel = new AppModel(model).Build(compiler: CppCompilerType.MSVC); + var appModel = new AppModel(model, makeDefaultBuild: false).Build(compiler: CppCompilerType.MSVC); var nameSuffix = i++ > 0 ? "-" + (i - 1) : ""; new CSharpCodeStubs(model) {