Fix dotnet run double dash passing arguments
When run “dotnet run -- foo”, foo should be the argument passed to the subject app. After replacing the original parser, dotnet-run did not utilize the “unparsedtoken” of the parsed result. To append unparsedtoken to RunCommand’s argument is not straight forward. RunCommand has an “immutable constructor”, which is a good thing, so I made update RunCommand’s argument following the immutable pattern -- create a new object with the original field but only change the arguments. I also made these filed private set.
This commit is contained in:
parent
6f57f27621
commit
83f3a3ec86
7 changed files with 115 additions and 21 deletions
29
test/dotnet.Tests/ParserTests/RunParserTests.cs
Normal file
29
test/dotnet.Tests/ParserTests/RunParserTests.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Tools.Run;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.Tests.ParserTests
|
||||
{
|
||||
public class RunParserTests
|
||||
{
|
||||
public RunParserTests(ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
private readonly ITestOutputHelper output;
|
||||
|
||||
[Fact]
|
||||
public void RunParserCanGetArguementFromDoubleDash()
|
||||
{
|
||||
var runCommand = RunCommand.FromArgs(new[]{ "--", "foo" });
|
||||
runCommand.Args.Single().Should().Be("foo");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue