Skip to content

Commit

Permalink
Remove saveDir and fixedGuid command line arguments: Please use ICSha…
Browse files Browse the repository at this point in the history
…rpCode.Decompiler.Console instead.
  • Loading branch information
siegfriedpammer committed Dec 10, 2017
1 parent a356f0e commit f77ee4f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 44 deletions.
11 changes: 0 additions & 11 deletions ILSpy/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ sealed class CommandLineArguments
public string Search;
public string Language;
public bool NoActivate;
public Guid? FixedGuid;
public string SaveDirectory;

public CommandLineArguments(IEnumerable<string> arguments)
{
Expand All @@ -51,15 +49,6 @@ public CommandLineArguments(IEnumerable<string> arguments)
this.Language = arg.Substring("/language:".Length);
else if (arg.Equals("/noActivate", StringComparison.OrdinalIgnoreCase))
this.NoActivate = true;
else if (arg.StartsWith("/fixedGuid:", StringComparison.OrdinalIgnoreCase)) {
string guid = arg.Substring("/fixedGuid:".Length);
if (guid.Length < 32)
guid = guid + new string('0', 32 - guid.Length);
Guid fixedGuid;
if (Guid.TryParse(guid, out fixedGuid))
this.FixedGuid = fixedGuid;
} else if (arg.StartsWith("/saveDir:", StringComparison.OrdinalIgnoreCase))
this.SaveDirectory = arg.Substring("/saveDir:".Length);
} else {
this.AssembliesToLoad.Add(arg);
}
Expand Down
1 change: 0 additions & 1 deletion ILSpy/Languages/CSharpLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput outp
var module = assembly.GetModuleDefinitionAsync().Result;
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {
var decompiler = new ILSpyWholeProjectDecompiler(assembly, options);
decompiler.ProjectGuid = App.CommandLineArguments.FixedGuid;
decompiler.DecompileProject(module, options.SaveAsProjectDirectory, new TextOutputWriter(output), options.CancellationToken);
} else {
AddReferenceWarningMessage(module.Assembly, output);
Expand Down
35 changes: 3 additions & 32 deletions ILSpy/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,9 @@ bool HandleCommandLineArguments(CommandLineArguments args)
return true;
}

async void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args)
void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args)
{
// if a SaveDirectory is given, do not start a second concurrent decompilation
// by executing JumpoToReference (leads to https://github.com/icsharpcode/ILSpy/issues/710)
if (!string.IsNullOrEmpty(args.SaveDirectory)) {
var tasks = commandLineLoadedAssemblies.Select(a => a.GetModuleDefinitionAsync()).ToArray();
var modules = await Task.WhenAll(tasks);
ExportAssemblies(modules, args.SaveDirectory);
} else if (args.NavigateTo != null) {
if (args.NavigateTo != null) {
bool found = false;
if (args.NavigateTo.StartsWith("N:", StringComparison.Ordinal)) {
string namespaceName = args.NavigateTo.Substring(2);
Expand Down Expand Up @@ -308,29 +302,6 @@ async void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args)
commandLineLoadedAssemblies.Clear(); // clear references once we don't need them anymore
}

void ExportAssemblies(ModuleDefinition[] modules, string path)
{
Language language = sessionSettings.FilterSettings.Language;
TextView.SaveAssembliesToDisk(language, modules.Select(m => assemblyListTreeNode.FindAssemblyNode(m)).Where(m => m != null).ToArray(), path);
}

void OnExportAssembly(Task<ModuleDefinition> moduleTask, string path)
{
AssemblyTreeNode asmNode = assemblyListTreeNode.FindAssemblyNode(moduleTask.Result);
if (asmNode != null) {
string file = DecompilerTextView.CleanUpName(asmNode.LoadedAssembly.ShortName);
Language language = sessionSettings.FilterSettings.Language;
DecompilationOptions options = new DecompilationOptions();
options.FullDecompilation = true;
options.SaveAsProjectDirectory = Path.Combine(path, file);
if (!Directory.Exists(options.SaveAsProjectDirectory)) {
Directory.CreateDirectory(options.SaveAsProjectDirectory);
}
string fullFile = Path.Combine(options.SaveAsProjectDirectory, file + language.ProjectFileExtension);
TextView.SaveToDisk(language, new[] { asmNode }, options, fullFile);
}
}

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
ILSpySettings spySettings = this.spySettings;
Expand Down Expand Up @@ -359,7 +330,7 @@ void MainWindow_Loaded(object sender, RoutedEventArgs e)
void OpenAssemblies(ILSpySettings spySettings)
{
HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments);
if (string.IsNullOrEmpty(App.CommandLineArguments.SaveDirectory) && App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) {
if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) {
SharpTreeNode node = null;
if (sessionSettings.ActiveTreeViewPath != null) {
node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true);
Expand Down

0 comments on commit f77ee4f

Please sign in to comment.