File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 1
- using System ;
1
+ #if ! PSV3
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
#if ! CORECLR
4
5
using System . ComponentModel . Composition ;
@@ -130,3 +131,5 @@ public SourceType GetSourceType()
130
131
}
131
132
}
132
133
}
134
+
135
+ #endif // !PSV3
Original file line number Diff line number Diff line change @@ -62,8 +62,14 @@ Describe "Test Name parameters" {
62
62
It " get Rules with no parameters supplied" {
63
63
$defaultRules = Get-ScriptAnalyzerRule
64
64
$expectedNumRules = 45
65
- if ((Test-PSEditionCoreClr ))
65
+ if ((Test-PSEditionCoreClr ) -or ( Test-PSVersionV3 ) )
66
66
{
67
+ # for PSv3 PSAvoidGlobalAliases is not shipped because
68
+ # it uses StaticParameterBinder.BindCommand which is
69
+ # available only on PSv4 and above
70
+ # for PowerShell Core, PSUseSingularNouns is not
71
+ # shipped because it uses APIs that are not present
72
+ # in dotnet core.
67
73
$expectedNumRules = 44
68
74
}
69
75
$defaultRules.Count | Should be $expectedNumRules
Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ Function Test-PSEditionCoreCLRLinux
38
38
(Test-PSEditionCoreCLR ) -and $IsLinux
39
39
}
40
40
41
+ Function Test-PSVersionV3
42
+ {
43
+ $PSVersionTable.PSVersion.Major -eq 3
44
+ }
45
+
41
46
Function Get-Count
42
47
{
43
48
Begin {$count = 0 }
@@ -49,4 +54,5 @@ Export-ModuleMember -Function Get-ExtentText
49
54
Export-ModuleMember - Function Test-CorrectionExtent
50
55
Export-ModuleMember - Function Test-PSEditionCoreCLR
51
56
Export-ModuleMember - Function Test-PSEditionCoreCLRLinux
57
+ Export-ModuleMember - Function Test-PSVersionV3
52
58
Export-ModuleMember - Function Get-Count
Original file line number Diff line number Diff line change 1
- Import-Module PSScriptAnalyzer
1
+ $directory = Split-Path - Parent $MyInvocation.MyCommand.Path
2
+ $testRootDirectory = Split-Path - Parent $directory
3
+ Import-Module (Join-Path $testRootDirectory ' PSScriptAnalyzerTestHelper.psm1' )
4
+ if ((Test-PSVersionV3 ))
5
+ {
6
+ return
7
+ }
8
+
9
+ Import-Module PSScriptAnalyzer
2
10
3
11
$AvoidGlobalAliasesError = " Avoid creating aliases with a Global scope."
4
12
$violationName = " PSAvoidGlobalAliases"
5
-
6
- $directory = Split-Path - Parent $MyInvocation.MyCommand.Path
7
13
$violations = Invoke-ScriptAnalyzer $directory \AvoidGlobalAliases.psm1 | Where-Object {$_.RuleName -eq $violationName }
8
14
$noViolations = Invoke-ScriptAnalyzer $directory \AvoidGlobalAliasesNoViolations.ps1 | Where-Object {$_.RuleName -eq $violationName }
9
15
You can’t perform that action at this time.
0 commit comments