Skip to content

Commit 0f5bf4e

Browse files
committed
Updates based on testing on WS2012R2 with PSv4
1 parent 698f198 commit 0f5bf4e

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Engine/Helper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ public bool IsDscResourceClassBased(ScriptBlockAst ast)
248248
return false;
249249
}
250250

251+
#if !PSV3
252+
251253
List<string> dscResourceFunctionNames = new List<string>(new string[] { "Test", "Get", "Set" });
252254

253255
IEnumerable<Ast> dscClasses = ast.FindAll(item =>
@@ -262,6 +264,8 @@ item is TypeDefinitionAst
262264
return true;
263265
}
264266

267+
#endif
268+
265269
return false;
266270
}
267271

@@ -934,13 +938,21 @@ internal List<RuleSuppression> GetSuppressionsClass(TypeDefinitionAst typeAst)
934938

935939
if (typeAst.Members == null)
936940
{
937-
return result;
938-
}
941+
return result;
942+
}
939943

940944
foreach (var member in typeAst.Members)
941945
{
946+
#if PSv3
947+
948+
FunctionDefinitionAst funcMemb = member as FunctionDefinitionAst;
949+
950+
#else
951+
942952
FunctionMemberAst funcMemb = member as FunctionMemberAst;
943953

954+
#endif
955+
944956
if (funcMemb == null)
945957
{
946958
continue;

PSScriptAnalyzer.sln

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ Global
1515
Release|Any CPU = Release|Any CPU
1616
EndGlobalSection
1717
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.ActiveCfg = Release|Any CPU
19-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.Build.0 = Release|Any CPU
18+
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.ActiveCfg = PSV3 Debug|Any CPU
19+
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.Build.0 = PSV3 Debug|Any CPU
2020
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.PSV3 Debug|Any CPU.ActiveCfg = PSV3 Debug|Any CPU
2121
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.PSV3 Debug|Any CPU.Build.0 = PSV3 Debug|Any CPU
2222
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.PSV3 Release|Any CPU.ActiveCfg = PSV3 Release|Any CPU
2323
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.PSV3 Release|Any CPU.Build.0 = PSV3 Release|Any CPU
2424
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.ActiveCfg = Release|Any CPU
2525
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.ActiveCfg = Release|Any CPU
27-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.Build.0 = Release|Any CPU
26+
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.ActiveCfg = PSV3 Debug|Any CPU
27+
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.Build.0 = PSV3 Debug|Any CPU
2828
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.PSV3 Debug|Any CPU.ActiveCfg = Debug|Any CPU
2929
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.PSV3 Debug|Any CPU.Build.0 = Debug|Any CPU
3030
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.PSV3 Release|Any CPU.ActiveCfg = Release|Any CPU

Rules/PossibleIncorrectComparisonWithNull.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
4848
}
4949
}
5050

51+
#if PSV3
52+
53+
IEnumerable<Ast> funcAsts = ast.FindAll(item => item is FunctionDefinitionAst, true);
54+
55+
#else
56+
5157
IEnumerable<Ast> funcAsts = ast.FindAll(item => item is FunctionDefinitionAst, true).Union(ast.FindAll(item => item is FunctionMemberAst, true));
58+
59+
#endif
60+
5261
foreach (Ast funcAst in funcAsts)
5362
{
5463
IEnumerable<Ast> binAsts = funcAst.FindAll(item => item is BinaryExpressionAst, true);

0 commit comments

Comments
 (0)