commandlineparser / commandlineparser/commandline
"help" crashes when mixing UsageAttribute with other Attributes
- 主要語言
- C#
- 星號
- 4.8k
- 分支
- 478
- PR 合併指標
- 30 天內沒有已合併 PR
描述
**Issue by [LarsWeuste](https://github.com/LarsWeuste)**
_Friday May 19, 2017 at 10:47 GMT_
_Originally opened as https://github.com/gsscoder/commandline/issues/443_
----
When using the "Usage" attribute together with a 2nd one (e.g. ExcludeFromCoverage) like this:
[Usage]
[ExcludeFromCodeCoverage]
public static IEnumerable Examples ...
In this situation displaying "help" will cause an exception.
The cause for that is likely fixed by this change:
src/CommandLine/Core/ReflectionExtensions.cs: L45
public static Maybe> GetUsageData(this Type type)
{
return
(from pi in type.FlattenHierarchy().SelectMany(x => x.GetTypeInfo().GetProperties())
let attrs = pi.GetCustomAttributes(true)
where attrs.OfType().Any()
select Tuple.Create(pi, (UsageAttribute)attrs.OfType().First()))
.SingleOrDefault()
.ToMaybe();
}
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
從 src/CommandLine/Core/ReflectionExtensions.cs 開始,特別查看第 45 行附近的 GetUsageData。在同一個 property 上使用 Usage 和 ExcludeFromCodeCoverage 屬性重現 help 命令,然後確認 help 顯示時不會發生例外,且相關行為仍由現有測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 52/100