Fix IsPublic and move publicizer out of the remapper
This commit is contained in:
parent
ce86e9dd15
commit
34434e1a50
56
AssemblyRemapper/Reflection/Publicizer.cs
Normal file
56
AssemblyRemapper/Reflection/Publicizer.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user