diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 178efa6..ffc40fb 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -281,14 +281,12 @@ public partial class ReCodeItForm : Form : DataProvider.Remaps; var existingRemap = remaps - .Where(remap => remap.NewTypeName == newRemap.NewTypeName) - .FirstOrDefault(); + .FirstOrDefault(remap => remap.NewTypeName == newRemap.NewTypeName); if (existingRemap == null) { existingRemap = remaps - .Where(remap => _cachedNewTypeNames.Contains(remap.NewTypeName)) - .FirstOrDefault(); + .FirstOrDefault(remap => _cachedNewTypeNames.Contains(remap.NewTypeName)); } // Handle overwriting an existing remap diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index efa0797..6ece109 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -148,22 +148,22 @@ public class ReCodeItRemapper Definition = type, }; - var matches = new HashSet + var matches = new List { - type.MatchIsAbstract(remap.SearchParams, score), - type.MatchIsEnum(remap.SearchParams, score) , - type.MatchIsNested(remap.SearchParams, score), - type.MatchIsSealed(remap.SearchParams, score) , - type.MatchIsDerived(remap.SearchParams, score) , - type.MatchIsInterface(remap.SearchParams, score), - type.MatchHasGenericParameters(remap.SearchParams, score), - type.MatchIsPublic(remap.SearchParams, score) , - type.MatchHasAttribute(remap.SearchParams, score), type.MatchConstructors(remap.SearchParams, score), type.MatchMethods(remap.SearchParams, score), type.MatchFields(remap.SearchParams, score), type.MatchProperties(remap.SearchParams, score), - type.MatchNestedTypes(remap.SearchParams, score) + type.MatchNestedTypes(remap.SearchParams, score), + type.MatchIsPublic(remap.SearchParams, score) , + type.MatchIsInterface(remap.SearchParams, score), + type.MatchIsAbstract(remap.SearchParams, score), + type.MatchIsSealed(remap.SearchParams, score) , + type.MatchIsEnum(remap.SearchParams, score) , + type.MatchIsNested(remap.SearchParams, score), + type.MatchIsDerived(remap.SearchParams, score) , + type.MatchHasGenericParameters(remap.SearchParams, score), + type.MatchHasAttribute(remap.SearchParams, score), }; var NoMatch = matches.Where(x => x.Equals(EMatchResult.NoMatch)).FirstOrDefault(); @@ -268,7 +268,7 @@ public class ReCodeItRemapper Logger.Log($"Renaming {highestScore.Definition.Name} to {highestScore.ProposedNewName}", ConsoleColor.Green); Logger.Log($"Scored: {highestScore.Score} points", ConsoleColor.Green); - if (filteredScores.Count() > 1) + if (filteredScores.Count() > 1 && filteredScores.Skip(1).Any(score => score.Score == highestScore.Score)) { Logger.Log($"Warning! There were {filteredScores.Count()} possible matches. Considering adding more search parameters, Only showing first 5.", ConsoleColor.Yellow); diff --git a/RecodeItLib/Remapper/Search/TypeDefExtensions.cs b/RecodeItLib/Remapper/Search/TypeDefExtensions.cs index 9d3f8da..99e76fe 100644 --- a/RecodeItLib/Remapper/Search/TypeDefExtensions.cs +++ b/RecodeItLib/Remapper/Search/TypeDefExtensions.cs @@ -156,13 +156,15 @@ internal static class TypeDefExtensions return EMatchResult.Disabled; } - if (parms.IsPublic == false && type.IsNotPublic) + if ((bool)!parms.IsPublic && type.IsNotPublic) { + Logger.Log($"Match {type.Name}"); score.Score++; return EMatchResult.Match; } - else if ((bool)parms.IsPublic && type.IsPublic) + + if ((bool)parms.IsPublic && type.IsPublic) { score.Score++; return EMatchResult.Match; diff --git a/Templates/Settings.jsonc b/Templates/Settings.jsonc index 1198d39..09778fe 100644 --- a/Templates/Settings.jsonc +++ b/Templates/Settings.jsonc @@ -50,6 +50,7 @@ "Class", "GClass", "GStruct", + "Interface", "GInterface" ], "PropertyFieldBlackList": [ // Property or fields names to ignore in the automap, these are case sanitized so case does not matter