Skip to content

Commit bc1bb08

Browse files
committed
Merge pull request #411 from PowerShell/ScriptAnalyzerPSV3Branch
PSv3 support for ScriptAnalyzer
2 parents 5868cff + c4f3a44 commit bc1bb08

30 files changed

+711
-117
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public class InvokeScriptAnalyzerCommand : PSCmdlet, IOutputWriter
4343
/// </summary>
4444
[Parameter(Position = 0,
4545
ParameterSetName = "File",
46-
Mandatory = true)]
46+
Mandatory = true,
47+
ValueFromPipeline = true,
48+
ValueFromPipelineByPropertyName = true)]
4749
[ValidateNotNull]
4850
[Alias("PSPath")]
4951
public string Path
@@ -58,7 +60,9 @@ public string Path
5860
/// </summary>
5961
[Parameter(Position = 0,
6062
ParameterSetName = "ScriptDefinition",
61-
Mandatory = true)]
63+
Mandatory = true,
64+
ValueFromPipeline = true,
65+
ValueFromPipelineByPropertyName = true)]
6266
[ValidateNotNull]
6367
public string ScriptDefinition
6468
{

Engine/Generic/IDSCResourceRule.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ public interface IDSCResourceRule : IRule
2828
/// <returns>The results of the analysis</returns>
2929
IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName);
3030

31+
#if !PSV3
32+
3133
/// <summary>
3234
/// Analyze dsc classes (if any) in the file
3335
/// </summary>
3436
/// <param name="ast"></param>
3537
/// <param name="fileName"></param>
3638
/// <returns></returns>
3739
IEnumerable<DiagnosticRecord> AnalyzeDSCClass(Ast ast, string fileName);
38-
40+
41+
#endif
42+
3943
}
4044
}

Engine/Generic/RuleSuppression.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,14 @@ public static List<RuleSuppression> GetSuppressions(IEnumerable<AttributeAst> at
367367
targetAsts = scopeAst.FindAll(item => item is FunctionDefinitionAst && reg.IsMatch((item as FunctionDefinitionAst).Name), true);
368368
goto default;
369369

370+
#if !PSV3
371+
370372
case "class":
371373
targetAsts = scopeAst.FindAll(item => item is TypeDefinitionAst && reg.IsMatch((item as TypeDefinitionAst).Name), true);
372374
goto default;
373375

376+
#endif
377+
374378
default:
375379
break;
376380
}

0 commit comments

Comments
 (0)