diff --git a/AssemblyRemapper/Reflection/Publicizer.cs b/AssemblyRemapper/Reflection/Publicizer.cs new file mode 100644 index 0000000..777090e --- /dev/null +++ b/AssemblyRemapper/Reflection/Publicizer.cs @@ -0,0 +1,56 @@ +using AssemblyRemapper.Utils; + +namespace AssemblyRemapper.Reflection; + +internal static class Publicizer +{ + public static void Publicize() + { + if (!DataProvider.AppSettings.Publicize) { return; } + + Logger.Log("Starting publicization...", ConsoleColor.Green); + + foreach (var type in DataProvider.ModuleDefinition.Types) + { + if (type.IsNotPublic) { type.IsPublic = true; } + + // We only want to do methods and properties + + if (type.HasMethods) + { + foreach (var method in type.Methods) + { + method.IsPublic = true; + } + } + + if (type.HasProperties) + { + foreach (var property in type.Properties) + { + if (property.SetMethod != null) + { + property.SetMethod.IsPublic = true; + } + + if (property.GetMethod != null) + { + property.GetMethod.IsPublic = true; + } + } + } + } + } + + public static void Unseal() + { + if (!DataProvider.AppSettings.Unseal) { return; } + + Logger.Log("Starting unseal...", ConsoleColor.Green); + + foreach (var type in DataProvider.ModuleDefinition.Types) + { + if (type.IsSealed) { type.IsSealed = false; } + } + } +} \ No newline at end of file diff --git a/AssemblyRemapper/Reflection/Remapper.cs b/AssemblyRemapper/Reflection/Remapper.cs index 2fb1609..a2da241 100644 --- a/AssemblyRemapper/Reflection/Remapper.cs +++ b/AssemblyRemapper/Reflection/Remapper.cs @@ -23,8 +23,8 @@ internal class Remapper if (DataProvider.AppSettings.ScoringMode) { return; } // Dont publicize and unseal until after the remapping so we can use those as search parameters - HandlePublicize(); - HandleUnseal(); + Publicizer.Publicize(); + Publicizer.Unseal(); // We are done, write the assembly WriteAssembly(); @@ -53,56 +53,6 @@ internal class Remapper } } - private void HandlePublicize() - { - if (!DataProvider.AppSettings.Publicize) { return; } - - Logger.Log("Starting publicization...", ConsoleColor.Green); - - foreach (var type in DataProvider.ModuleDefinition.Types) - { - if (type.IsNotPublic) { type.IsPublic = true; } - - // We only want to do methods and properties - - if (type.HasMethods) - { - foreach (var method in type.Methods) - { - method.IsPublic = true; - } - } - - if (type.HasProperties) - { - foreach (var property in type.Properties) - { - if (property.SetMethod != null) - { - property.SetMethod.IsPublic = true; - } - - if (property.GetMethod != null) - { - property.GetMethod.IsPublic = true; - } - } - } - } - } - - private void HandleUnseal() - { - if (!DataProvider.AppSettings.Unseal) { return; } - - Logger.Log("Starting unseal...", ConsoleColor.Green); - - foreach (var type in DataProvider.ModuleDefinition.Types) - { - if (type.IsSealed) { type.IsSealed = false; } - } - } - private EFailureReason ScoreType(TypeDefinition type, RemapModel remap, string parentTypeName = "") { // Handle Direct Remaps by strict naming first bypasses everything else @@ -192,6 +142,7 @@ internal class Remapper return EFailureReason.HasNestedTypes; } + remap.OriginalTypeName = type.Name; score.AddScoreToResult(); return EFailureReason.None; @@ -204,6 +155,8 @@ internal class Remapper var oldName = type.Name; type.Name = remap.NewTypeName; + remap.OriginalTypeName = type.Name; + Logger.Log("-----------------------------------------------", ConsoleColor.Green); Logger.Log($"Renamed {oldName} to {type.Name} directly", ConsoleColor.Green); diff --git a/AssemblyRemapper/Reflection/SearchProvider.cs b/AssemblyRemapper/Reflection/SearchProvider.cs index 03d0e5f..8f6c23e 100644 --- a/AssemblyRemapper/Reflection/SearchProvider.cs +++ b/AssemblyRemapper/Reflection/SearchProvider.cs @@ -139,9 +139,12 @@ internal static class SearchProvider return EMatchResult.Disabled; } - var boolToCheck = parms.IsPublic == true ? type.IsPublic : type.IsNotPublic; - - if (boolToCheck == !parms.IsPublic) + if (parms.IsPublic is false && type.IsNotPublic is true) + { + score.Score++; + return EMatchResult.Match; + } + else if (parms.IsPublic is true && type.IsPublic is true) { score.Score++; return EMatchResult.Match;