Closed
Description
Here is a minimal reproduction
var command = new Command("command")
{
new Argument<bool>("a"),
new Argument<int>("b"),
new Argument<string>("c"),
new Argument<double>("d"),
};
new Parser(command).Parse(new[] { "a" });
Here 1/4 arguments are passed (3 missing). The same will reproduce with e.g. 1/5 or 2/5 arguments, but not 1/3 or 2/4.
The types of the arguments also don't seem to matter.
Expected result: The method completes without throwing exceptions.
Actual result: An exception is thrown:
System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.CommandLine.Parsing.ParseResultVisitor.ValidateAndConvertArgumentResults(IReadOnlyList`1 arguments, Int32 commandArgumentResultCount) in .../src/System.CommandLine/Parsing/ParseResultVisitor.cs:line 294
at System.CommandLine.Parsing.ParseResultVisitor.Stop() in .../src/System.CommandLine/Parsing/ParseResultVisitor.cs:line 251
at System.CommandLine.Parsing.ParseResultVisitor.Visit(SyntaxNode node) in .../src/System.CommandLine/Parsing/ParseResultVisitor.cs:line 56
at System.CommandLine.Parsing.Parser.Parse(IReadOnlyList`1 arguments, String rawInput) in .../src/System.CommandLine/Parsing/Parser.cs:line 64
at System.CommandLine.Tests.MyTest.MyTestCase() in .../src/System.CommandLine.Tests/MyTest.cs:line 19
The above stack trace is from current main branch.
Metadata
Metadata
Assignees
Labels
No labels