Skip to content

Commit

Permalink
Merge branch 'lmmarsano-fix-attribute-error' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
moh-hassan committed Aug 19, 2020
2 parents 690136e + d64451e commit 074d050
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/CommandLine/Core/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static Maybe<Tuple<PropertyInfo, UsageAttribute>> GetUsageData(this Type
{
return
(from pi in type.FlattenHierarchy().SelectMany(x => x.GetTypeInfo().GetProperties())
let attrs = pi.GetCustomAttributes(true)
where attrs.OfType<UsageAttribute>().Any()
let attrs = pi.GetCustomAttributes(typeof(UsageAttribute), true)
where attrs.Any()
select Tuple.Create(pi, (UsageAttribute)attrs.First()))
.SingleOrDefault()
.ToMaybe();
Expand Down
4 changes: 4 additions & 0 deletions tests/CommandLine.Tests/Fakes/CustomAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System;

[AttributeUsage(AttributeTargets.All)]
class CustomAttribute: Attribute {}
4 changes: 3 additions & 1 deletion tests/CommandLine.Tests/Fakes/Help_Fakes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class Options_With_Usage_Attribute
[Option("secert-option", Hidden = true, HelpText = "This is a description for a secert hidden option that should never be visibile to the user via help text.")]
public string SecertOption { get; set; }

[Usage(ApplicationAlias = "mono testapp.exe")]
[ Custom
, Usage(ApplicationAlias = "mono testapp.exe")
]
public static IEnumerable<Example> Examples
{
get
Expand Down

0 comments on commit 074d050

Please sign in to comment.