Skip to content

Commit

Permalink
Switch to per-line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwille committed May 13, 2024
1 parent 049b867 commit 84b78b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ILSpy.AddIn.Shared/ILSpyInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions ILSpy.Tests/CommandLineArgumentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ILSpy/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CommandLineArguments(IEnumerable<string> 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
Expand Down

0 comments on commit 84b78b3

Please sign in to comment.