Skip to content

Commit a05dbae

Browse files
author
Quoc Truong
committed
Merge pull request #244 from PowerShell/FixAvoidDefaultValueSwitchParameter
Fix Null pointer exception in avoid default value switch parameter
2 parents 3eb56c6 + 83d6d5f commit a05dbae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Rules/AvoidDefaultTrueValueSwitchParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
3939
// Iterrates all ParamAsts and check if any are switch.
4040
foreach (ParameterAst paramAst in paramAsts)
4141
{
42-
if (paramAst.Attributes.Any(attr => string.Equals(attr.TypeName.GetReflectionType().FullName, "system.management.automation.switchparameter", StringComparison.OrdinalIgnoreCase))
42+
if (paramAst.Attributes.Any(attr => attr.TypeName.GetReflectionType() == typeof(System.Management.Automation.SwitchParameter))
4343
&& paramAst.DefaultValue != null && String.Equals(paramAst.DefaultValue.Extent.Text, "$true", StringComparison.OrdinalIgnoreCase))
4444
{
4545
yield return new DiagnosticRecord(

0 commit comments

Comments
 (0)