commandlineparser / commandlineparser/commandline

Example with Option with IEnumerable<string> broken - Sequence contains more than one element

未關閉
#377 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
good first issue
主要語言
C#
星號
4.8k
分支
478
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

在 .NET Core 2.1 上使用所示的 IEnumerable 選項和兩個 --read 值重現此失敗。從堆疊追蹤中出現的 CommandLine.Core.InstanceBuilder.Build 和 ReflectionExtensions.SetProperties 開始。完成標準是:對包含多個輸入檔案的範例進行剖析時,不再出現 Sequence contains more than one element 例外,且剖析能夠完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp
領域
cli
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。