Skip to content

Commit 489938a

Browse files
author
Kapil Borle
committed
Add method to check for cmdletbinding attribute
1 parent 49b5e0a commit 489938a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Engine/Extensions.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ public static AttributeAst GetCmdletBindingAttributeAst(this ParamBlockAst param
5656
{
5757
throw new ArgumentNullException("attributeAsts");
5858
}
59+
5960
foreach (var attributeAst in attributeAsts)
6061
{
61-
if (attributeAst == null || attributeAst.NamedArguments == null)
62-
{
63-
continue;
64-
}
65-
if (attributeAst.TypeName.GetReflectionAttributeType()
66-
== typeof(CmdletBindingAttribute))
62+
if (attributeAst != null && attributeAst.IsCmdletBindingAttributeAst())
6763
{
6864
return attributeAst;
6965
}
7066
}
67+
7168
return null;
7269
}
70+
71+
public static bool IsCmdletBindingAttributeAst(this AttributeAst attributeAst)
72+
{
73+
return attributeAst.TypeName.GetReflectionAttributeType() == typeof(CmdletBindingAttribute);
74+
}
7375
}
7476
}

0 commit comments

Comments
 (0)