Skip to content

Commit af02e80

Browse files
authored
Add ErrorView to SpecialVars.cs (#1865)
* add ErrorView to SpecialVars and create test * Changed type of ErrorView
1 parent 772997f commit af02e80

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Engine/SpecialVars.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static SpecialVars()
9191
internal const string ConfirmPreference = "ConfirmPreference";
9292
internal const string ProgressPreference = "ProgressPreference";
9393
internal const string InformationPreference = "InformationPreference";
94+
internal const string ErrorView = "ErrorView";
9495

9596
internal static readonly string[] PreferenceVariables = new string[]
9697
{
@@ -101,7 +102,8 @@ static SpecialVars()
101102
WarningPreference,
102103
ConfirmPreference,
103104
ProgressPreference,
104-
InformationPreference
105+
InformationPreference,
106+
ErrorView
105107
};
106108

107109
internal static readonly Type[] PreferenceVariableTypes = new Type[]
@@ -114,6 +116,7 @@ static SpecialVars()
114116
/* ConfirmPreference */ typeof(ConfirmImpact),
115117
/* ProgressPreference */ typeof(Enum),
116118
/* InformationPreference */ typeof(ActionPreference),
119+
/* ErrorView */ typeof(Enum), //ErrorView type not available on PS3
117120
};
118121

119122
internal enum AutomaticVariable

Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ function MyFunc2() {
7272
}
7373

7474
Context "When there are no violations" {
75+
It "No warning is issued for assignment without use of preference variable ErrorView" {
76+
$results = Invoke-ScriptAnalyzer -ScriptDefinition '$ErrorView = NormalView'
77+
$results.Count | Should -Be 0
78+
}
79+
7580
It "returns no violations" {
7681
$noViolations.Count | Should -Be 0
7782
}

0 commit comments

Comments
 (0)