6
6
7
7
namespace Microsoft . Windows . PowerShell . ScriptAnalyzer . Extensions
8
8
{
9
- // TODO Add documentation
10
9
public static class Extensions
11
10
{
11
+ /// <summary>
12
+ /// Return the lines in a text string.
13
+ /// </summary>
14
+ /// <param name="text">Text string to be split around new lines.</param>
15
+ /// <returns></returns>
12
16
public static IEnumerable < string > GetLines ( this string text )
13
17
{
14
18
return text . Split ( '\n ' ) . Select ( line => line . TrimEnd ( '\r ' ) ) ;
@@ -26,6 +30,13 @@ public static Range ToRange(this IScriptExtent extent)
26
30
extent . EndColumnNumber ) ;
27
31
}
28
32
33
+ /// <summary>
34
+ /// Get the parameter Asts from a function definition Ast.
35
+ ///
36
+ /// If not parameters are found, return null.
37
+ /// </summary>
38
+ /// <param name="paramBlockAst">If a parameter block is present, set this argument's value to the parameter block.</param>
39
+ /// <returns></returns>
29
40
public static IEnumerable < ParameterAst > GetParameterAsts (
30
41
this FunctionDefinitionAst functionDefinitionAst ,
31
42
out ParamBlockAst paramBlockAst )
@@ -68,11 +79,19 @@ public static AttributeAst GetCmdletBindingAttributeAst(this ParamBlockAst param
68
79
return null ;
69
80
}
70
81
82
+ /// <summary>
83
+ /// Check if an attribute Ast is of CmdletBindingAttribute type.
84
+ /// </summary>
71
85
public static bool IsCmdletBindingAttributeAst ( this AttributeAst attributeAst )
72
86
{
73
87
return attributeAst . TypeName . GetReflectionAttributeType ( ) == typeof ( CmdletBindingAttribute ) ;
74
88
}
75
89
90
+ /// <summary>
91
+ /// Given a CmdletBinding attribute ast, return the SupportsShouldProcess argument Ast.
92
+ ///
93
+ /// If no SupportsShouldProcess argument is found, return null.
94
+ /// </summary>
76
95
public static NamedAttributeArgumentAst GetSupportsShouldProcessAst ( this AttributeAst attributeAst )
77
96
{
78
97
if ( ! attributeAst . IsCmdletBindingAttributeAst ( )
@@ -95,6 +114,10 @@ public static NamedAttributeArgumentAst GetSupportsShouldProcessAst(this Attribu
95
114
return null ;
96
115
}
97
116
117
+ /// <summary>
118
+ /// Return the boolean value of a named attribute argument.
119
+ /// </summary>
120
+ /// <param name="argumentAst">The ast of the argument's value</param>
98
121
public static bool IsTrue ( this NamedAttributeArgumentAst attrAst , out ExpressionAst argumentAst )
99
122
{
100
123
argumentAst = null ;
0 commit comments