Skip to content

Commit b418142

Browse files
author
Kapil Borle
committed
Add documentation to extension methods
1 parent 5902d24 commit b418142

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Engine/Extensions.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Extensions
88
{
9-
// TODO Add documentation
109
public static class Extensions
1110
{
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>
1216
public static IEnumerable<string> GetLines(this string text)
1317
{
1418
return text.Split('\n').Select(line => line.TrimEnd('\r'));
@@ -26,6 +30,13 @@ public static Range ToRange(this IScriptExtent extent)
2630
extent.EndColumnNumber);
2731
}
2832

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>
2940
public static IEnumerable<ParameterAst> GetParameterAsts(
3041
this FunctionDefinitionAst functionDefinitionAst,
3142
out ParamBlockAst paramBlockAst)
@@ -68,11 +79,19 @@ public static AttributeAst GetCmdletBindingAttributeAst(this ParamBlockAst param
6879
return null;
6980
}
7081

82+
/// <summary>
83+
/// Check if an attribute Ast is of CmdletBindingAttribute type.
84+
/// </summary>
7185
public static bool IsCmdletBindingAttributeAst(this AttributeAst attributeAst)
7286
{
7387
return attributeAst.TypeName.GetReflectionAttributeType() == typeof(CmdletBindingAttribute);
7488
}
7589

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>
7695
public static NamedAttributeArgumentAst GetSupportsShouldProcessAst(this AttributeAst attributeAst)
7796
{
7897
if (!attributeAst.IsCmdletBindingAttributeAst()
@@ -95,6 +114,10 @@ public static NamedAttributeArgumentAst GetSupportsShouldProcessAst(this Attribu
95114
return null;
96115
}
97116

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>
98121
public static bool IsTrue(this NamedAttributeArgumentAst attrAst, out ExpressionAst argumentAst)
99122
{
100123
argumentAst = null;

0 commit comments

Comments
 (0)