mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 15:10:44 -05:00
Fix ambiguous methods, make end logging use sync
This commit is contained in:
parent
298a2aac04
commit
542b81540d
@ -105,8 +105,15 @@ public class ReMapper
|
||||
{
|
||||
renameTasks.Add(
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
renamer.RenameAll(types, remap);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogSync($"Exception in task: {ex.Message}", ConsoleColor.Red);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -37,18 +37,22 @@ internal class Renamer
|
||||
{
|
||||
List<MethodDef> methodsToFix = [];
|
||||
|
||||
methodsToFix.AddRange(
|
||||
from method in type.Methods where method.Name.StartsWith(remap.TypePrimeCandidate!.Name.String)
|
||||
let splitName = method.Name.String.Split(".") where splitName.Length != 1 select method);
|
||||
var allMethodNames = type.Methods
|
||||
.Select(s => s.Name).ToList();
|
||||
|
||||
foreach (var method in methodsToFix)
|
||||
var methodsWithInterfaces =
|
||||
(from method in type.Methods
|
||||
where method.Name.StartsWith(remap.TypePrimeCandidate!.Name.String)
|
||||
select method).ToList();
|
||||
|
||||
foreach (var method in methodsWithInterfaces.ToArray())
|
||||
{
|
||||
var name = method.Name.String.Split(".");
|
||||
|
||||
if (methodsToFix.Count(m => m.Name.String.EndsWith(name[1])) > 1)
|
||||
if (allMethodNames.Count(n => n.EndsWith(name[1])) > 1)
|
||||
continue;
|
||||
|
||||
method.Name = name[1];
|
||||
method.Name = method.Name.String.Split(".")[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public class Statistics(
|
||||
if (!validate)
|
||||
{
|
||||
DisplayWriteAssembly();
|
||||
|
||||
// In-case a thread is handing
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,11 +41,11 @@ public class Statistics(
|
||||
|
||||
private void DisplayAlternativeMatches(RemapModel remap)
|
||||
{
|
||||
Logger.Log($"Warning! There were {remap.TypeCandidates.Count()} possible matches for {remap.NewTypeName}. Consider adding more search parameters, Only showing the first 5.", ConsoleColor.Yellow);
|
||||
Logger.LogSync($"Warning! There were {remap.TypeCandidates.Count()} possible matches for {remap.NewTypeName}. Consider adding more search parameters, Only showing the first 5.", ConsoleColor.Yellow);
|
||||
|
||||
foreach (var type in remap.TypeCandidates.Skip(1).Take(5))
|
||||
{
|
||||
Logger.Log($"{type.Name}", ConsoleColor.Yellow);
|
||||
Logger.LogSync($"{type.Name}", ConsoleColor.Yellow);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,25 +59,25 @@ public class Statistics(
|
||||
switch (remap.Succeeded)
|
||||
{
|
||||
case false when remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch):
|
||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
||||
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
||||
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||
Logger.LogSync("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||
Logger.LogSync("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
||||
Logger.LogSync($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
||||
Logger.LogSync($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
||||
Logger.LogSync("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||
|
||||
failures++;
|
||||
break;
|
||||
case false:
|
||||
{
|
||||
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
||||
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
||||
Logger.LogSync("-----------------------------------------------", ConsoleColor.Red);
|
||||
Logger.LogSync($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
||||
|
||||
foreach (var reason in remap.NoMatchReasons)
|
||||
{
|
||||
Logger.Log($"Reason: {reason}", ConsoleColor.Red);
|
||||
Logger.LogSync($"Reason: {reason}", ConsoleColor.Red);
|
||||
}
|
||||
|
||||
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
||||
Logger.LogSync("-----------------------------------------------", ConsoleColor.Red);
|
||||
failures++;
|
||||
continue;
|
||||
}
|
||||
@ -94,17 +97,17 @@ public class Statistics(
|
||||
|
||||
var renamedColor = changes > 0 ? ConsoleColor.Green : ConsoleColor.Yellow;
|
||||
|
||||
Logger.Log($"Renamed {changes} types", renamedColor);
|
||||
Logger.LogSync($"Renamed {changes} types", renamedColor);
|
||||
|
||||
var failColor = failures > 0 ? ConsoleColor.Red : ConsoleColor.Green;
|
||||
|
||||
Logger.Log($"Failed to rename {failures} types", failColor);
|
||||
Logger.LogSync($"Failed to rename {failures} types", failColor);
|
||||
}
|
||||
|
||||
private void DisplayWriteAssembly()
|
||||
{
|
||||
Logger.Log($"Assembly written to `{outPath}`", ConsoleColor.Green);
|
||||
Logger.Log($"Hollowed written to `{hollowedPath}`", ConsoleColor.Green);
|
||||
Logger.Log($"Remap took {stopwatch.Elapsed.TotalSeconds:F1} seconds", ConsoleColor.Green);
|
||||
Logger.LogSync($"Assembly written to `{outPath}`", ConsoleColor.Green);
|
||||
Logger.LogSync($"Hollowed written to `{hollowedPath}`", ConsoleColor.Green);
|
||||
Logger.LogSync($"Remap took {stopwatch.Elapsed.TotalSeconds:F1} seconds", ConsoleColor.Green);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user