commandlineparser / commandlineparser/commandline

"help" crashes when mixing UsageAttribute with other Attributes

オープン
#136 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
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();
}

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。