diff --git a/Engine/SpecialVars.cs b/Engine/SpecialVars.cs index 26f1afcf7..0b820c0d4 100644 --- a/Engine/SpecialVars.cs +++ b/Engine/SpecialVars.cs @@ -91,6 +91,7 @@ static SpecialVars() internal const string ConfirmPreference = "ConfirmPreference"; internal const string ProgressPreference = "ProgressPreference"; internal const string InformationPreference = "InformationPreference"; + internal const string ErrorView = "ErrorView"; internal static readonly string[] PreferenceVariables = new string[] { @@ -101,7 +102,8 @@ static SpecialVars() WarningPreference, ConfirmPreference, ProgressPreference, - InformationPreference + InformationPreference, + ErrorView }; internal static readonly Type[] PreferenceVariableTypes = new Type[] @@ -114,6 +116,7 @@ static SpecialVars() /* ConfirmPreference */ typeof(ConfirmImpact), /* ProgressPreference */ typeof(Enum), /* InformationPreference */ typeof(ActionPreference), + /* ErrorView */ typeof(Enum), //ErrorView type not available on PS3 }; internal enum AutomaticVariable diff --git a/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 b/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 index 983ac017f..823334afb 100644 --- a/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 +++ b/Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1 @@ -72,6 +72,11 @@ function MyFunc2() { } Context "When there are no violations" { + It "No warning is issued for assignment without use of preference variable ErrorView" { + $results = Invoke-ScriptAnalyzer -ScriptDefinition '$ErrorView = NormalView' + $results.Count | Should -Be 0 + } + It "returns no violations" { $noViolations.Count | Should -Be 0 }