File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
154154 }
155155 }
156156
157+ #if ! PSV3
157158 var configAsts = tokenOps . Ast . FindAll ( ast => ast is ConfigurationDefinitionAst , true ) ;
158159 if ( configAsts != null )
159160 {
@@ -169,7 +170,7 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
169170 groups . AddRange ( GetCommandElementExtentGroups ( configAst ) ) ;
170171 }
171172 }
172-
173+ #endif
173174
174175 // it is probably much easier have a hashtable writer that formats the hashtable and writes it
175176 // but it makes handling comments hard. So we need to use this approach.
@@ -183,8 +184,6 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
183184 // find the distance between the assignment operators and their corresponding LHS
184185 // find the longest left expression
185186 // make sure all the assignment operators are in the same column as that of the longest left hand.
186-
187-
188187 foreach ( var extentTuples in groups )
189188 {
190189 if ( ! HasPropertiesOnSeparateLines ( extentTuples ) )
Original file line number Diff line number Diff line change @@ -89,9 +89,10 @@ Configuration MyDscConfiguration {
8989 }
9090 }
9191
92- Context " When assignment statements are in DSC Configuration that has parse errors" {
93- It " Sdhould find violations when assignment statements are not aligned" {
94- $def = @'
92+ if ($PSVersionTable.PSVersion.Major -ge 5 ) {
93+ Context " When assignment statements are in DSC Configuration that has parse errors" {
94+ It " Should find violations when assignment statements are not aligned" {
95+ $def = @'
9596Configuration Sample_ChangeDescriptionAndPermissions
9697{
9798 Import-DscResource -Module NonExistentModule
@@ -112,12 +113,13 @@ Configuration Sample_ChangeDescriptionAndPermissions
112113 }
113114}
114115'@
115- # This invocation will throw parse error caused by "Undefined DSC resource" because
116- # NonExistentModule is not really avaiable to load. Therefore we set erroraction to
117- # SilentlyContinue
118- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings - ErrorAction SilentlyContinue |
119- Get-Count |
120- Should Be 4
116+ # This invocation will throw parse error caused by "Undefined DSC resource" because
117+ # NonExistentModule is not really avaiable to load. Therefore we set erroraction to
118+ # SilentlyContinue
119+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings - ErrorAction SilentlyContinue |
120+ Get-Count |
121+ Should Be 4
122+ }
121123 }
122124 }
123125}
You can’t perform that action at this time.
0 commit comments