mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 14:50:44 -05:00
Fix ambiguous methods, make end logging use sync
This commit is contained in:
parent
298a2aac04
commit
542b81540d
@ -106,7 +106,14 @@ public class ReMapper
|
|||||||
renameTasks.Add(
|
renameTasks.Add(
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
renamer.RenameAll(types, remap);
|
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 = [];
|
List<MethodDef> methodsToFix = [];
|
||||||
|
|
||||||
methodsToFix.AddRange(
|
var allMethodNames = type.Methods
|
||||||
from method in type.Methods where method.Name.StartsWith(remap.TypePrimeCandidate!.Name.String)
|
.Select(s => s.Name).ToList();
|
||||||
let splitName = method.Name.String.Split(".") where splitName.Length != 1 select method);
|
|
||||||
|
|
||||||
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(".");
|
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;
|
continue;
|
||||||
|
|
||||||
method.Name = name[1];
|
method.Name = method.Name.String.Split(".")[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@ public class Statistics(
|
|||||||
if (!validate)
|
if (!validate)
|
||||||
{
|
{
|
||||||
DisplayWriteAssembly();
|
DisplayWriteAssembly();
|
||||||
|
|
||||||
|
// In-case a thread is handing
|
||||||
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +41,11 @@ public class Statistics(
|
|||||||
|
|
||||||
private void DisplayAlternativeMatches(RemapModel remap)
|
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))
|
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)
|
switch (remap.Succeeded)
|
||||||
{
|
{
|
||||||
case false when remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch):
|
case false when remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch):
|
||||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
Logger.LogSync("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||||
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
Logger.LogSync("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
|
||||||
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
Logger.LogSync($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
|
||||||
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
Logger.LogSync($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
|
||||||
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
|
Logger.LogSync("----------------------------------------------------------------------", ConsoleColor.Red);
|
||||||
|
|
||||||
failures++;
|
failures++;
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
{
|
{
|
||||||
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
|
Logger.LogSync("-----------------------------------------------", ConsoleColor.Red);
|
||||||
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
Logger.LogSync($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
|
||||||
|
|
||||||
foreach (var reason in remap.NoMatchReasons)
|
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++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -94,17 +97,17 @@ public class Statistics(
|
|||||||
|
|
||||||
var renamedColor = changes > 0 ? ConsoleColor.Green : ConsoleColor.Yellow;
|
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;
|
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()
|
private void DisplayWriteAssembly()
|
||||||
{
|
{
|
||||||
Logger.Log($"Assembly written to `{outPath}`", ConsoleColor.Green);
|
Logger.LogSync($"Assembly written to `{outPath}`", ConsoleColor.Green);
|
||||||
Logger.Log($"Hollowed written to `{hollowedPath}`", ConsoleColor.Green);
|
Logger.LogSync($"Hollowed written to `{hollowedPath}`", ConsoleColor.Green);
|
||||||
Logger.Log($"Remap took {stopwatch.Elapsed.TotalSeconds:F1} seconds", ConsoleColor.Green);
|
Logger.LogSync($"Remap took {stopwatch.Elapsed.TotalSeconds:F1} seconds", ConsoleColor.Green);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user