Move warning message to EndProcessing so it only shows up once (#9385)
This commit is contained in:
parent
600a93750e
commit
5e58e30d20
|
@ -30,6 +30,14 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// </summary>
|
||||
[Parameter]
|
||||
public ConfigScope Scope { get; set; } = ConfigScope.CurrentUser;
|
||||
|
||||
/// <summary>
|
||||
/// EndProcessing method.
|
||||
/// </summary>
|
||||
protected override void EndProcessing()
|
||||
{
|
||||
WriteWarning(ExperimentalFeatureStrings.ExperimentalFeaturePending);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -87,8 +95,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
cmdlet.WriteError(new ErrorRecord(new ItemNotFoundException(errMsg), "ItemNotFoundException", ErrorCategory.ObjectNotFound, name));
|
||||
return;
|
||||
}
|
||||
|
||||
cmdlet.WriteWarning(ExperimentalFeatureStrings.ExperimentalFeaturePending);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,4 +94,14 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
|
|||
& $cmdlet ExpTest.FeatureOne -WarningVariable warning -WarningAction SilentlyContinue
|
||||
$warning | Should -Not -BeNullOrEmpty -Because "A warning message is always given indicating restart is required"
|
||||
}
|
||||
|
||||
It "Multiple features enabled will only output one warning message for <cmdlet>" -TestCases @(
|
||||
@{ cmdlet = "Enable-ExperimentalFeature" },
|
||||
@{ cmdlet = "Disable-Experimentalfeature" }
|
||||
) {
|
||||
param ($cmdlet)
|
||||
|
||||
Get-ExperimentalFeature | & $cmdlet -WarningAction SilentlyContinue -WarningVariable warning
|
||||
$warning | Should -HaveCount 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue