From 84b78b399f03fc67ccb86872d34e2ca5607428e8 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Mon, 13 May 2024 07:04:21 +0200 Subject: [PATCH] Switch to per-line arguments --- ILSpy.AddIn.Shared/ILSpyInstance.cs | 2 +- ILSpy.Tests/CommandLineArgumentsTests.cs | 12 ++++++++++-- ILSpy/CommandLineArguments.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ILSpy.AddIn.Shared/ILSpyInstance.cs b/ILSpy.AddIn.Shared/ILSpyInstance.cs index f43f9552cc..42059aa775 100644 --- a/ILSpy.AddIn.Shared/ILSpyInstance.cs +++ b/ILSpy.AddIn.Shared/ILSpyInstance.cs @@ -52,7 +52,7 @@ public void Start() if ((commandLineArguments != null) && commandLineArguments.Any()) { - string assemblyArguments = string.Join(" ", commandLineArguments); + string assemblyArguments = string.Join("\r\n", commandLineArguments); string filepath = Path.GetTempFileName(); File.WriteAllText(filepath, assemblyArguments); diff --git a/ILSpy.Tests/CommandLineArgumentsTests.cs b/ILSpy.Tests/CommandLineArgumentsTests.cs index 6efe430a46..659281df9d 100644 --- a/ILSpy.Tests/CommandLineArgumentsTests.cs +++ b/ILSpy.Tests/CommandLineArgumentsTests.cs @@ -100,14 +100,22 @@ public void MultipleAssembliesAsArguments() } [Test] - public void PassAtFileArgumentsSpaceSeparated() + public void PassAtFileArguments() { string filepath = System.IO.Path.GetTempFileName(); - System.IO.File.WriteAllText(filepath, "assembly1 assembly2 assembly3 --newinstance --noactivate"); + System.IO.File.WriteAllText(filepath, "assembly1\r\nassembly2\r\nassembly3\r\n--newinstance\r\n--noactivate"); var cmdLineArgs = new CommandLineArguments(new string[] { $"@{filepath}" }); + try + { + System.IO.File.Delete(filepath); + } + catch (Exception) + { + } + cmdLineArgs.SingleInstance.Should().BeFalse(); cmdLineArgs.NoActivate.Should().BeTrue(); cmdLineArgs.AssembliesToLoad.Should().HaveCount(3); diff --git a/ILSpy/CommandLineArguments.cs b/ILSpy/CommandLineArguments.cs index 541e8a7685..d481414805 100644 --- a/ILSpy/CommandLineArguments.cs +++ b/ILSpy/CommandLineArguments.cs @@ -40,7 +40,7 @@ public CommandLineArguments(IEnumerable arguments) { var app = new CommandLineApplication() { // https://natemcmaster.github.io/CommandLineUtils/docs/response-file-parsing.html?tabs=using-attributes - ResponseFileHandling = ResponseFileHandling.ParseArgsAsSpaceSeparated, + ResponseFileHandling = ResponseFileHandling.ParseArgsAsLineSeparated, // Note: options are case-sensitive (!), and, default behavior would be UnrecognizedArgumentHandling.Throw on Parse() // UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.CollectAndContinue