Hello,
DragonFruit looks sweet and I look forward to using it someday. Thank you!
I think I'm seeing a bug in System.CommandLine,DragonFruit. Full details below. Please let me know if I can help with finding and fixing.
OS: Windows 10 Professional
.Net Core: 3.1.201
IDE: Visual Studio 2019 v16.5.3
System.CommandLine,DragonFruit: 0.3.0-alpha.20213.1
https://github.com/urig/dragonfruit-repro
Add a NuGet dependency on DargonFruit:
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20213.1" />
Change the Main() to accept two string arguments and print them:
static void Main(string foo, string bar)
{
Console.WriteLine($"foo is {foo}");
Console.WriteLine($"bar is {bar}");
}
Build and run the Console Application with the foo argument:
ConsoleApplication1.exe --foo foo
string foo should be set to 'foo' and string bar should be set to null, printing:
foo is foo
bar is
string foo is set to 'foo' and string bar is also set to 'foo', printing:
foo is foo
bar is foo
Same behaviour also with
rootCommand.Handler = CommandHandler.Create<string, string>(Export);
It seems, that the types are checked only.
Fixed by #853
This appears to be the same issue as #854. Please try the latest release from nuget.org and let us know if you're still seeing the issue.
I tried writing a unit test that would detect the actual behavior, in (CommandLineTests.cs):
[Fact]
public async Task It_executes_method_with_two_strings()
{
int exitCode = await CommandLine.InvokeMethodAsync(
new[] { "--first", "Bruce" },
TestProgram.TestMainWithTwoStringsMethodInfo,
null,
_testProgram,
_terminal);
exitCode.Should().Be(0);
// expected actual value to be "Bruce Bruce", but it isn't and this passes:
_terminal.Out.ToString().Should().Be("Bruce ");
}
But the behavior is not reproduced when I run it. What am I missing?
Which version are you using?
I can confirm this is fixed for me in 0.3.0-alpha.20214.1. Joy 馃榾
Thank you @jonsequitur @Keboo 馃檹馃徎