mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 17:10:45 -05:00
Add regensig command
This commit is contained in:
parent
8041089f44
commit
632fe1bb5e
@ -17,7 +17,7 @@ public class AutoMatchCommand : ICommand
|
|||||||
[CommandParameter(1, IsRequired = true, Description = "Path to your mapping file so it can be updated if a match is found")]
|
[CommandParameter(1, IsRequired = true, Description = "Path to your mapping file so it can be updated if a match is found")]
|
||||||
public string MappingsPath { get; init; }
|
public string MappingsPath { get; init; }
|
||||||
|
|
||||||
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace")]
|
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")]
|
||||||
public required string OldTypeName { get; init; }
|
public required string OldTypeName { get; init; }
|
||||||
|
|
||||||
[CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")]
|
[CommandParameter(3, IsRequired = true, Description = "The name you want the type to be renamed to")]
|
||||||
|
45
ReCodeItCLI/Commands/RegenerateSignature.cs
Normal file
45
ReCodeItCLI/Commands/RegenerateSignature.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using ReCodeItCLI.Utils;
|
||||||
|
using ReCodeItLib.ReMapper;
|
||||||
|
using ReCodeItLib.Utils;
|
||||||
|
|
||||||
|
namespace ReCodeItCLI.Commands;
|
||||||
|
|
||||||
|
[Command("regensig", Description = "regenerates the signature of a mapping if it is failing")]
|
||||||
|
public class RegenerateSignature : CliFx.ICommand
|
||||||
|
{
|
||||||
|
[CommandParameter(0, IsRequired = true, Description = "The absolute path to the assembly you want to regenerate the signature for")]
|
||||||
|
public required string AssemblyPath { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(1, IsRequired = true, Description = "The absolute path to mapping.json")]
|
||||||
|
public required string MappingPath { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(2, IsRequired = true, Description = "Full old type name including namespace `Foo.Bar` for nested classes `Foo.Bar/FooBar`")]
|
||||||
|
public required string OldTypeName { get; init; }
|
||||||
|
|
||||||
|
[CommandParameter(3, IsRequired = true, Description = "The new type name as listed in the mapping file")]
|
||||||
|
public required string NewTypeName { get; init; }
|
||||||
|
|
||||||
|
|
||||||
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
Debugger.TryWaitForDebuggerAttach();
|
||||||
|
|
||||||
|
DataProvider.Settings.MappingPath = MappingPath;
|
||||||
|
var remaps = DataProvider.LoadMappingFile(MappingPath);
|
||||||
|
|
||||||
|
var target = remaps.SingleOrDefault(r => r.NewTypeName == NewTypeName);
|
||||||
|
|
||||||
|
if (target is null)
|
||||||
|
{
|
||||||
|
Logger.LogSync("Could not find signature to regenerate", ConsoleColor.Red);
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
new AutoMatcher(remaps, MappingPath)
|
||||||
|
.AutoMatch(AssemblyPath, OldTypeName, NewTypeName);
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user