diff --git a/AssemblyRemapper/Reflection/Remapper.cs b/AssemblyRemapper/Reflection/Remapper.cs index 3ac2377..6b5cfd4 100644 --- a/AssemblyRemapper/Reflection/Remapper.cs +++ b/AssemblyRemapper/Reflection/Remapper.cs @@ -7,6 +7,9 @@ namespace AssemblyRemapper.Reflection; internal class Remapper { + /// + /// Start the remapping process + /// public void InitializeRemap() { DisplayBasicModuleInformation(); @@ -30,6 +33,9 @@ internal class Remapper WriteAssembly(); } + /// + /// Display information about the module we are remapping + /// private void DisplayBasicModuleInformation() { Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); @@ -40,6 +46,10 @@ internal class Remapper Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); } + /// + /// Loop over all types in the assembly and score them + /// + /// Mapping to score private void HandleMapping(RemapModel mapping) { foreach (var type in DataProvider.ModuleDefinition.Types) @@ -53,7 +63,14 @@ internal class Remapper } } - private EFailureReason ScoreType(TypeDefinition type, RemapModel remap, string parentTypeName = "") + /// + /// Score the type against the remap checking against all remap properties + /// + /// Type to score + /// Remap to check against + /// + /// Failure reason or none if matched + private EFailureReason ScoreType(TypeDefinition type, RemapModel remap) { // Handle Direct Remaps by strict naming first bypasses everything else if (remap.UseForceRename) @@ -64,7 +81,7 @@ internal class Remapper foreach (var nestedType in type.NestedTypes) { - ScoreType(nestedType, remap, type.Name); + ScoreType(nestedType, remap); } var score = new ScoringModel @@ -181,11 +198,14 @@ internal class Remapper Logger.Log("-----------------------------------------------", ConsoleColor.Green); } + /// + /// Choose the best possible match from all remaps + /// private void ChooseBestMatches() { foreach (var score in DataProvider.ScoringModels) { - ChooseBestMatch(score.Value, true); + ChooseBestMatch(score.Value); } var failures = 0; @@ -210,7 +230,11 @@ internal class Remapper Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); } - private void ChooseBestMatch(HashSet scores, bool isBest = false) + /// + /// Choose best match from a collection of scores, then start the renaming process + /// + /// Scores to rate + private void ChooseBestMatch(HashSet scores) { if (scores.Count == 0) { return; } @@ -218,10 +242,6 @@ internal class Remapper if (highestScore is null) { return; } - var potentialText = isBest - ? "Best potential" - : "Next potential"; - Logger.Log("-----------------------------------------------", ConsoleColor.Green); Logger.Log($"Renaming {highestScore.Definition.Name} to {highestScore.ProposedNewName}", ConsoleColor.Green); Logger.Log($"Max possible score: {highestScore.ReMap.SearchParams.CalculateMaxScore()}", ConsoleColor.Green); @@ -245,6 +265,9 @@ internal class Remapper Logger.Log("-----------------------------------------------", ConsoleColor.Green); } + /// + /// Write the assembly back to disk and update the mapping file on disk + /// private void WriteAssembly() { var filename = Path.GetFileNameWithoutExtension(DataProvider.AppSettings.AssemblyPath);