Bug fixes

This commit is contained in:
Cj 2024-06-14 14:18:17 -04:00
parent 711419e426
commit ff40bd4ca3
4 changed files with 66 additions and 32 deletions

View File

@ -9,6 +9,8 @@ namespace AssemblyRemapper.Remapper;
public class Remapper public class Remapper
{ {
public static bool IsRunning { get; private set; } = false;
private static Stopwatch Stopwatch = new(); private static Stopwatch Stopwatch = new();
/// <summary> /// <summary>
@ -16,6 +18,7 @@ public class Remapper
/// </summary> /// </summary>
public void InitializeRemap() public void InitializeRemap()
{ {
IsRunning = true;
DisplayBasicModuleInformation(); DisplayBasicModuleInformation();
Stopwatch.Start(); Stopwatch.Start();
@ -29,7 +32,11 @@ public class Remapper
ChooseBestMatches(); ChooseBestMatches();
if (DataProvider.Settings.AppSettings.MatchMode) { return; } if (DataProvider.Settings.AppSettings.MatchMode)
{
IsRunning = false;
return;
}
// Dont publicize and unseal until after the remapping so we can use those as search parameters // Dont publicize and unseal until after the remapping so we can use those as search parameters
if (!DataProvider.Settings.Remapper.Publicize) if (!DataProvider.Settings.Remapper.Publicize)
@ -243,7 +250,7 @@ public class Remapper
var remappedPath = Path.Combine(strippedPath, filename); var remappedPath = Path.Combine(strippedPath, filename);
DataProvider.AssemblyDefinition.Write(remappedPath); DataProvider.AssemblyDefinition.Write(remappedPath);
//DataProvider.UpdateMapping(); DataProvider.UpdateMapping();
Logger.Log("-----------------------------------------------", ConsoleColor.Green); Logger.Log("-----------------------------------------------", ConsoleColor.Green);
Logger.Log($"Complete: Assembly written to `{remappedPath}`", ConsoleColor.Green); Logger.Log($"Complete: Assembly written to `{remappedPath}`", ConsoleColor.Green);
@ -251,6 +258,19 @@ public class Remapper
Logger.Log($"Remap took {Stopwatch.Elapsed.TotalSeconds:F0} seconds", ConsoleColor.Green); Logger.Log($"Remap took {Stopwatch.Elapsed.TotalSeconds:F0} seconds", ConsoleColor.Green);
Logger.Log("-----------------------------------------------", ConsoleColor.Green); Logger.Log("-----------------------------------------------", ConsoleColor.Green);
Stopwatch.Stop(); Reset();
IsRunning = false;
}
private void Reset()
{
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log("Reloading assembly definitions", ConsoleColor.Yellow);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
DataProvider.LoadAssemblyDefinition();
DataProvider.ScoringModels = [];
Stopwatch.Reset();
} }
} }

View File

@ -127,6 +127,9 @@ public static class DataProvider
public static void LoadAssemblyDefinition() public static void LoadAssemblyDefinition()
{ {
AssemblyDefinition = null;
ModuleDefinition = null;
DefaultAssemblyResolver resolver = new(); DefaultAssemblyResolver resolver = new();
resolver.AddSearchDirectory(Path.GetDirectoryName(Settings.Remapper.AssemblyPath)); // Replace with the correct path : (6/14) I have no idea what I met by that resolver.AddSearchDirectory(Path.GetDirectoryName(Settings.Remapper.AssemblyPath)); // Replace with the correct path : (6/14) I have no idea what I met by that
ReaderParameters parameters = new() { AssemblyResolver = resolver }; ReaderParameters parameters = new() { AssemblyResolver = resolver };

View File

@ -33,10 +33,11 @@ partial class AssemblyToolGUI
TabPageRemapper = new TabPage(); TabPageRemapper = new TabPage();
RemapTreeView = new TreeView(); RemapTreeView = new TreeView();
groupBox1 = new GroupBox(); groupBox1 = new GroupBox();
ConstuctorCountUpDown = new NumericUpDown();
ConstructorCountEnabled = new CheckBox();
LoadMappingFileButton = new Button(); LoadMappingFileButton = new Button();
SaveMappingFileButton = new Button(); SaveMappingFileButton = new Button();
RunRemapButton = new Button(); RunRemapButton = new Button();
ScoreButton = new Button();
Inclusions = new TabControl(); Inclusions = new TabControl();
tabPage1 = new TabPage(); tabPage1 = new TabPage();
ExcludeMethodTextBox = new TextBox(); ExcludeMethodTextBox = new TextBox();
@ -104,6 +105,7 @@ partial class AssemblyToolGUI
((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit(); ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
TabPageRemapper.SuspendLayout(); TabPageRemapper.SuspendLayout();
groupBox1.SuspendLayout(); groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
Inclusions.SuspendLayout(); Inclusions.SuspendLayout();
tabPage1.SuspendLayout(); tabPage1.SuspendLayout();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
@ -137,10 +139,11 @@ partial class AssemblyToolGUI
// //
// groupBox1 // groupBox1
// //
groupBox1.Controls.Add(ConstuctorCountUpDown);
groupBox1.Controls.Add(ConstructorCountEnabled);
groupBox1.Controls.Add(LoadMappingFileButton); groupBox1.Controls.Add(LoadMappingFileButton);
groupBox1.Controls.Add(SaveMappingFileButton); groupBox1.Controls.Add(SaveMappingFileButton);
groupBox1.Controls.Add(RunRemapButton); groupBox1.Controls.Add(RunRemapButton);
groupBox1.Controls.Add(ScoreButton);
groupBox1.Controls.Add(Inclusions); groupBox1.Controls.Add(Inclusions);
groupBox1.Controls.Add(NewTypeName); groupBox1.Controls.Add(NewTypeName);
groupBox1.Controls.Add(ForceRenameCheckbox); groupBox1.Controls.Add(ForceRenameCheckbox);
@ -174,6 +177,23 @@ partial class AssemblyToolGUI
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Remap Editor"; groupBox1.Text = "Remap Editor";
// //
// ConstuctorCountUpDown
//
ConstuctorCountUpDown.Location = new Point(224, 178);
ConstuctorCountUpDown.Name = "ConstuctorCountUpDown";
ConstuctorCountUpDown.Size = new Size(55, 31);
ConstuctorCountUpDown.TabIndex = 19;
//
// ConstructorCountEnabled
//
ConstructorCountEnabled.AutoSize = true;
ConstructorCountEnabled.Location = new Point(287, 184);
ConstructorCountEnabled.Name = "ConstructorCountEnabled";
ConstructorCountEnabled.Size = new Size(238, 29);
ConstructorCountEnabled.TabIndex = 20;
ConstructorCountEnabled.Text = "Constructor Param Count";
ConstructorCountEnabled.UseVisualStyleBackColor = true;
//
// LoadMappingFileButton // LoadMappingFileButton
// //
LoadMappingFileButton.Location = new Point(601, 489); LoadMappingFileButton.Location = new Point(601, 489);
@ -196,7 +216,7 @@ partial class AssemblyToolGUI
// //
// RunRemapButton // RunRemapButton
// //
RunRemapButton.Location = new Point(580, 185); RunRemapButton.Location = new Point(580, 145);
RunRemapButton.Name = "RunRemapButton"; RunRemapButton.Name = "RunRemapButton";
RunRemapButton.Size = new Size(168, 34); RunRemapButton.Size = new Size(168, 34);
RunRemapButton.TabIndex = 16; RunRemapButton.TabIndex = 16;
@ -204,16 +224,6 @@ partial class AssemblyToolGUI
RunRemapButton.UseVisualStyleBackColor = true; RunRemapButton.UseVisualStyleBackColor = true;
RunRemapButton.Click += RunRemapButton_Click; RunRemapButton.Click += RunRemapButton_Click;
// //
// ScoreButton
//
ScoreButton.Location = new Point(580, 145);
ScoreButton.Name = "ScoreButton";
ScoreButton.Size = new Size(168, 34);
ScoreButton.TabIndex = 5;
ScoreButton.Text = "Score Remap";
ScoreButton.UseVisualStyleBackColor = true;
ScoreButton.Click += ScoreButton_Click;
//
// Inclusions // Inclusions
// //
Inclusions.Controls.Add(tabPage1); Inclusions.Controls.Add(tabPage1);
@ -616,7 +626,7 @@ partial class AssemblyToolGUI
// PropertyCountEnabled // PropertyCountEnabled
// //
PropertyCountEnabled.AutoSize = true; PropertyCountEnabled.AutoSize = true;
PropertyCountEnabled.Location = new Point(287, 258); PropertyCountEnabled.Location = new Point(287, 291);
PropertyCountEnabled.Name = "PropertyCountEnabled"; PropertyCountEnabled.Name = "PropertyCountEnabled";
PropertyCountEnabled.Size = new Size(159, 29); PropertyCountEnabled.Size = new Size(159, 29);
PropertyCountEnabled.TabIndex = 11; PropertyCountEnabled.TabIndex = 11;
@ -635,7 +645,7 @@ partial class AssemblyToolGUI
// NestedTypeCountEnabled // NestedTypeCountEnabled
// //
NestedTypeCountEnabled.AutoSize = true; NestedTypeCountEnabled.AutoSize = true;
NestedTypeCountEnabled.Location = new Point(287, 293); NestedTypeCountEnabled.Location = new Point(287, 326);
NestedTypeCountEnabled.Name = "NestedTypeCountEnabled"; NestedTypeCountEnabled.Name = "NestedTypeCountEnabled";
NestedTypeCountEnabled.Size = new Size(189, 29); NestedTypeCountEnabled.Size = new Size(189, 29);
NestedTypeCountEnabled.TabIndex = 12; NestedTypeCountEnabled.TabIndex = 12;
@ -644,7 +654,7 @@ partial class AssemblyToolGUI
// //
// PropertyCountUpDown // PropertyCountUpDown
// //
PropertyCountUpDown.Location = new Point(224, 258); PropertyCountUpDown.Location = new Point(224, 291);
PropertyCountUpDown.Name = "PropertyCountUpDown"; PropertyCountUpDown.Name = "PropertyCountUpDown";
PropertyCountUpDown.Size = new Size(55, 31); PropertyCountUpDown.Size = new Size(55, 31);
PropertyCountUpDown.TabIndex = 5; PropertyCountUpDown.TabIndex = 5;
@ -661,7 +671,7 @@ partial class AssemblyToolGUI
// //
// FieldCountUpDown // FieldCountUpDown
// //
FieldCountUpDown.Location = new Point(224, 220); FieldCountUpDown.Location = new Point(224, 253);
FieldCountUpDown.Name = "FieldCountUpDown"; FieldCountUpDown.Name = "FieldCountUpDown";
FieldCountUpDown.Size = new Size(55, 31); FieldCountUpDown.Size = new Size(55, 31);
FieldCountUpDown.TabIndex = 3; FieldCountUpDown.TabIndex = 3;
@ -678,7 +688,7 @@ partial class AssemblyToolGUI
// FieldCountEnabled // FieldCountEnabled
// //
FieldCountEnabled.AutoSize = true; FieldCountEnabled.AutoSize = true;
FieldCountEnabled.Location = new Point(287, 223); FieldCountEnabled.Location = new Point(287, 256);
FieldCountEnabled.Name = "FieldCountEnabled"; FieldCountEnabled.Name = "FieldCountEnabled";
FieldCountEnabled.Size = new Size(128, 29); FieldCountEnabled.Size = new Size(128, 29);
FieldCountEnabled.TabIndex = 13; FieldCountEnabled.TabIndex = 13;
@ -695,7 +705,7 @@ partial class AssemblyToolGUI
// //
// MethodCountUpDown // MethodCountUpDown
// //
MethodCountUpDown.Location = new Point(224, 182); MethodCountUpDown.Location = new Point(224, 215);
MethodCountUpDown.Name = "MethodCountUpDown"; MethodCountUpDown.Name = "MethodCountUpDown";
MethodCountUpDown.Size = new Size(55, 31); MethodCountUpDown.Size = new Size(55, 31);
MethodCountUpDown.TabIndex = 6; MethodCountUpDown.TabIndex = 6;
@ -745,7 +755,7 @@ partial class AssemblyToolGUI
// //
// NestedTypeCountUpDown // NestedTypeCountUpDown
// //
NestedTypeCountUpDown.Location = new Point(224, 296); NestedTypeCountUpDown.Location = new Point(224, 329);
NestedTypeCountUpDown.Name = "NestedTypeCountUpDown"; NestedTypeCountUpDown.Name = "NestedTypeCountUpDown";
NestedTypeCountUpDown.Size = new Size(55, 31); NestedTypeCountUpDown.Size = new Size(55, 31);
NestedTypeCountUpDown.TabIndex = 4; NestedTypeCountUpDown.TabIndex = 4;
@ -798,7 +808,7 @@ partial class AssemblyToolGUI
// MethodCountEnabled // MethodCountEnabled
// //
MethodCountEnabled.AutoSize = true; MethodCountEnabled.AutoSize = true;
MethodCountEnabled.Location = new Point(287, 188); MethodCountEnabled.Location = new Point(287, 221);
MethodCountEnabled.Name = "MethodCountEnabled"; MethodCountEnabled.Name = "MethodCountEnabled";
MethodCountEnabled.Size = new Size(154, 29); MethodCountEnabled.Size = new Size(154, 29);
MethodCountEnabled.TabIndex = 14; MethodCountEnabled.TabIndex = 14;
@ -837,6 +847,7 @@ partial class AssemblyToolGUI
TabPageRemapper.ResumeLayout(false); TabPageRemapper.ResumeLayout(false);
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);
groupBox1.PerformLayout(); groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).EndInit();
Inclusions.ResumeLayout(false); Inclusions.ResumeLayout(false);
tabPage1.ResumeLayout(false); tabPage1.ResumeLayout(false);
tabPage1.PerformLayout(); tabPage1.PerformLayout();
@ -860,7 +871,6 @@ partial class AssemblyToolGUI
private GroupBox groupBox1; private GroupBox groupBox1;
private TabControl Inclusions; private TabControl Inclusions;
private TabPage tabPage1; private TabPage tabPage1;
private NumericUpDown MethodCountUpDown;
private TextBox ExcludeMethodTextBox; private TextBox ExcludeMethodTextBox;
private TextBox IncludeMethodTextBox; private TextBox IncludeMethodTextBox;
private Button MethodExcludeRemoveButton; private Button MethodExcludeRemoveButton;
@ -905,7 +915,6 @@ partial class AssemblyToolGUI
private CheckBox ForceRenameCheckbox; private CheckBox ForceRenameCheckbox;
private TextBox OriginalTypeName; private TextBox OriginalTypeName;
private TextBox NewTypeName; private TextBox NewTypeName;
private Button ScoreButton;
private Button RemoveRemapButton; private Button RemoveRemapButton;
private Button AddRemapButton; private Button AddRemapButton;
private ListView RemapListView; private ListView RemapListView;
@ -919,7 +928,6 @@ partial class AssemblyToolGUI
private DomainUpDown IsNestedUpDown; private DomainUpDown IsNestedUpDown;
private DomainUpDown IsEnumUpDown; private DomainUpDown IsEnumUpDown;
private DomainUpDown IsAbstractUpDown; private DomainUpDown IsAbstractUpDown;
private CheckBox MethodCountEnabled;
private CheckBox FieldCountEnabled; private CheckBox FieldCountEnabled;
private CheckBox PropertyCountEnabled; private CheckBox PropertyCountEnabled;
private CheckBox NestedTypeCountEnabled; private CheckBox NestedTypeCountEnabled;
@ -928,4 +936,8 @@ partial class AssemblyToolGUI
private Button SaveMappingFileButton; private Button SaveMappingFileButton;
private Button RunRemapButton; private Button RunRemapButton;
private Button LoadMappingFileButton; private Button LoadMappingFileButton;
private NumericUpDown ConstuctorCountUpDown;
private CheckBox ConstructorCountEnabled;
private NumericUpDown MethodCountUpDown;
private CheckBox MethodCountEnabled;
} }

View File

@ -70,6 +70,7 @@ namespace AssemblyRemapperGUI
: BaseClassExcludeTextField.Text, : BaseClassExcludeTextField.Text,
// Constructor - TODO // Constructor - TODO
ConstructorParameterCount = ConstructorCountEnabled.GetCount(ConstuctorCountUpDown),
MethodCount = MethodCountEnabled.GetCount(MethodCountUpDown), MethodCount = MethodCountEnabled.GetCount(MethodCountUpDown),
FieldCount = FieldCountEnabled.GetCount(FieldCountUpDown), FieldCount = FieldCountEnabled.GetCount(FieldCountUpDown),
PropertyCount = PropertyCountEnabled.GetCount(PropertyCountUpDown), PropertyCount = PropertyCountEnabled.GetCount(PropertyCountUpDown),
@ -96,13 +97,11 @@ namespace AssemblyRemapperGUI
RemapTreeView.SelectedNode?.Remove(); RemapTreeView.SelectedNode?.Remove();
} }
private void ScoreButton_Click(object sender, EventArgs e)
{
}
private void RunRemapButton_Click(object sender, EventArgs e) private void RunRemapButton_Click(object sender, EventArgs e)
{ {
Remapper.InitializeRemap(); if (Remapper.IsRunning) { return; }
Task.Run(() => Remapper.InitializeRemap());
} }
private void SaveMappingFileButton_Click(object sender, EventArgs e) private void SaveMappingFileButton_Click(object sender, EventArgs e)