commandlineparser / commandlineparser/commandline

"help" crashes when mixing UsageAttribute with other Attributes

Đang mở
#136 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
4.8k
Fork
478
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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();
}

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.