commandlineparser / commandlineparser/commandline
Example with Option with IEnumerable<string> broken - Sequence contains more than one element
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 478
- PR merge metrics
- No merged PRs in 30d
Description
Running the latest commandlineparser v2.3.0 on .Net Core 2.1.
The library example doesn't seem to work at all parsing IEnumerable
[Option('r', "read", Required = true, HelpText = "Input files to be processed.")]
public IEnumerable InputFiles { get; set; }
If you specify --read file1 file2 you get this exception:
System.InvalidOperationException
HResult=0x80131509
Message=Sequence contains more than one element
Source=System.Linq
StackTrace:
> System.Linq.dll!System.Linq.Enumerable.Single(System.Collections.Generic.IEnumerable source) Line 45 C#
CommandLine.dll!CommandLine.Core.InstanceBuilder.Build.AnonymousMethod__0_23(CommandLine.Core.SpecificationProperty sp) Unknown
CommandLine.dll!CommandLine.Core.ReflectionExtensions.SetProperties.AnonymousMethod__0(System.__Canon current, CommandLine.Core.SpecificationProperty specProp) Unknown
System.Linq.dll!System.Linq.Enumerable.Aggregate(System.Collections.Generic.IEnumerable source, LogMerger.Program.Options seed, System.Func func) Line 55 C#
CommandLine.dll!CommandLine.Core.InstanceBuilder.Build.AnonymousMethod__16() Unknown
CommandLine.dll!CommandLine.Core.InstanceBuilder.Build.AnonymousMethod__7() Unknown
CommandLine.dll!CommandLine.Parser.ParseArguments(System.Collections.Generic.IEnumerable args) Unknown
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure on .NET Core 2.1 with the shown IEnumerable option and two --read values. Start at CommandLine.Core.InstanceBuilder.Build and ReflectionExtensions.SetProperties, which appear in the stack trace. Done means parsing the example with multiple input files completes without the Sequence contains more than one element exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100