@@ -15,6 +15,9 @@ $script:Win10_5_profile = 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.4
1515$script :Win10_6_1_profile = ' win-48_x64_10.0.17763.0_6.1.3_x64_4.0.30319.42000_core'
1616$script :Ubuntu1804_6_1_profile = ' ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core'
1717
18+ $script :AzF_profile = (Resolve-Path " $PSScriptRoot /../../PSCompatibilityCollector/optional_profiles/azurefunctions.json" ).Path
19+ $script :AzA_profile = (Resolve-Path " $PSScriptRoot /../../PSCompatibilityCollector/optional_profiles/azureautomation.json" ).Path
20+
1821$script :TypeCompatibilityTestCases = @ (
1922 @ { Target = $script :Srv2012_3_profile ; Script = ' [System.Management.Automation.ModuleIntrinsics]::GetModulePath("here", "there", "everywhere")' ; Types = @ (' System.Management.Automation.ModuleIntrinsics' ); Version = " 3.0" ; OS = ' Windows' ; ProblemCount = 1 }
2023 @ { Target = $script :Srv2012_3_profile ; Script = ' $ast -is [System.Management.Automation.Language.FunctionMemberAst]' ; Types = @ (' System.Management.Automation.Language.FunctionMemberAst' ); Version = " 3.0" ; OS = ' Windows' ; ProblemCount = 1 }
@@ -166,4 +169,53 @@ Describe 'UseCompatibleTypes' {
166169 $diagnostics.Count | Should - Be 0
167170 }
168171 }
172+
173+ Context ' Targeting new-form Az profiles alongside older profiles' {
174+ BeforeAll {
175+ $settings = @ {
176+ Rules = @ {
177+ $script :RuleName = @ {
178+ $script :TargetProfileConfigKey = @ (
179+ $script :AzF_profile
180+ $script :AzA_profile
181+ $script :Win10_5_profile
182+ )
183+ }
184+ }
185+ }
186+ }
187+
188+ It " Finds AzF problems with a script" {
189+ $diagnostics = Invoke-ScriptAnalyzer - IncludeRule $script :RuleName - Settings $settings - ScriptDefinition '
190+ [System.Collections.Immutable.ImmutableList[string]]::Empty
191+ [Microsoft.PowerShell.ToStringCodeMethods]::PropertyValueCollection($obj)
192+ '
193+
194+ $diagnostics.Count | Should - Be 2
195+ $diagnosticGroups = Group-Object $diagnostics - Property Type
196+ foreach ($group in $diagnosticGroups )
197+ {
198+ switch ($group.Name )
199+ {
200+ ' System.Collections.Immutable.ImmutableList[System.String]'
201+ {
202+ $group.Count | Should - Be 2
203+ $group [0 ].Group.TargetPlatform.PowerShell.Version.Major | Should - Be 5
204+ $group [1 ].Group.TargetPlatform.PowerShell.Version.Major | Should - Be 5
205+ }
206+
207+ ' Microsoft.PowerShellToStringCodeMethods'
208+ {
209+ $group.Count | Should - Be 1
210+ $group [0 ].Group.TargetPlatform.PowerShell.Version.Major | Should - Be 6
211+ }
212+
213+ default
214+ {
215+ $group | Should - Be $null
216+ }
217+ }
218+ }
219+ }
220+ }
169221}
0 commit comments