Add back Update-List command (#10922)

This commit is contained in:
Steve Lee
2019-10-30 11:05:30 -07:00
committed by Andrew
parent fab1e12fb7
commit 0b12ea057a
7 changed files with 34 additions and 8 deletions
@@ -33,12 +33,10 @@
<Compile Remove="commands\utility\ShowCommand\ShowCommandParameterSetInfo.cs" />
<Compile Remove="commands\utility\ShowCommand\ShowCommandParameterType.cs" />
<Compile Remove="commands\utility\ShowCommand\ShowCommandProxy.cs" />
<Compile Remove="commands\utility\Update-List.cs" />
<Compile Remove="singleshell\installer\MshUtilityMshSnapin.cs" />
<Compile Remove="gen\FormatAndOut_out_gridview.cs" />
<Compile Remove="gen\UtilityMshSnapinResources.cs" />
<Compile Remove="gen\OutPrinterDisplayStrings.cs" />
<Compile Remove="gen\UpdateListStrings.cs" />
<Compile Remove="gen\ConvertFromStringResources.cs" />
<Compile Remove="gen\ConvertStringResources.cs" />
<Compile Remove="gen\FlashExtractStrings.cs" />
@@ -47,7 +45,6 @@
<EmbeddedResource Remove="resources\FormatAndOut_out_gridview.resx" />
<EmbeddedResource Remove="resources\UtilityMshSnapinResources.resx" />
<EmbeddedResource Remove="resources\OutPrinterDisplayStrings.resx" />
<EmbeddedResource Remove="resources\UpdateListStrings.resx" />
<EmbeddedResource Remove="resources\ConvertFromStringResources.resx" />
<EmbeddedResource Remove="resources\ConvertStringResources.resx" />
<EmbeddedResource Remove="resources\FlashExtractStrings.resx" />
@@ -18,7 +18,7 @@ namespace Microsoft.PowerShell.Commands
/// (multi-valued parameter for a cmdlet), without exposing the list.
/// </summary>
[Cmdlet(VerbsData.Update, "List", DefaultParameterSetName = "AddRemoveSet",
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113447", RemotingCapability = RemotingCapability.None)]
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2109383", RemotingCapability = RemotingCapability.None)]
public class UpdateListCommand : PSCmdlet
{
/// <summary>
@@ -25,7 +25,7 @@ CmdletsToExport = @(
'Get-TraceSource', 'Set-TraceSource', 'Add-Type', 'Get-TypeData', 'Remove-TypeData', 'Update-TypeData',
'Get-UICulture', 'Get-Unique', 'Get-Uptime', 'Clear-Variable', 'Get-Variable', 'New-Variable',
'Remove-Variable', 'Set-Variable', 'Get-Verb', 'Write-Verbose', 'Write-Warning', 'Invoke-WebRequest',
'Format-Wide', 'ConvertTo-Xml', 'Select-Xml', 'Get-Error'
'Format-Wide', 'ConvertTo-Xml', 'Select-Xml', 'Get-Error', 'Update-List'
)
FunctionsToExport = @()
AliasesToExport = @('fhx')
@@ -23,7 +23,7 @@ CmdletsToExport = @(
'ConvertFrom-StringData', 'Format-Table', 'New-TemporaryFile', 'New-TimeSpan', 'Get-TraceSource', 'Set-TraceSource',
'Add-Type', 'Get-TypeData', 'Remove-TypeData', 'Update-TypeData', 'Get-UICulture', 'Get-Unique', 'Get-Uptime',
'Clear-Variable', 'Get-Variable', 'New-Variable', 'Remove-Variable', 'Set-Variable', 'Get-Verb', 'Write-Verbose',
'Write-Warning', 'Invoke-WebRequest', 'Format-Wide', 'ConvertTo-Xml', 'Select-Xml', 'Get-Error'
'Write-Warning', 'Invoke-WebRequest', 'Format-Wide', 'ConvertTo-Xml', 'Select-Xml', 'Get-Error', 'Update-List'
)
FunctionsToExport = @()
AliasesToExport = @('fhx')
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Update-List Tests" -Tag CI {
BeforeEach {
$testObj = [pscustomobject]@{a = [System.Collections.ArrayList]::new(@(1,2,3))}
}
It "-Add works" {
$testObj | Update-List -Property a -Add 4
$testObj.A | Should -Be 1,2,3,4
}
It "-Remove works" {
Update-List -InputObject $testObj -Property a -Remove 2
$testObj.A | Should -Be 1,3
}
It "-Add with -Remove works" {
$testObj | Update-List -Property a -Remove 2 -Add 4
$testObj.A | Should -Be 1,3,4
}
It "-Replace works" {
$testObj | Update-List -Property a -Replace 2,4
$testObj.A | Should -Be 2,4
}
}
@@ -475,7 +475,7 @@ Describe "Verify approved aliases list" -Tags "CI" {
"Cmdlet", "Unregister-PSSessionConfiguration","", $($FullCLR -or $CoreWindows ), "", "", "Low"
"Cmdlet", "Update-FormatData", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Low"
"Cmdlet", "Update-Help", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Medium"
"Cmdlet", "Update-List", "", $($FullCLR ), "", "", ""
"Cmdlet", "Update-List", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None"
"Cmdlet", "Update-TypeData", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Low"
"Cmdlet", "Use-Transaction", "", $($FullCLR ), "", "", ""
"Cmdlet", "Wait-Debugger", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None"
@@ -227,7 +227,7 @@ Undo-Transaction,https://go.microsoft.com/fwlink/?LinkID=135268
Unregister-Event,https://go.microsoft.com/fwlink/?LinkID=135269
Unregister-PSSessionConfiguration,https://go.microsoft.com/fwlink/?LinkID=144308
Update-FormatData,https://go.microsoft.com/fwlink/?LinkID=113420
Update-List,https://go.microsoft.com/fwlink/?LinkID=113447
Update-List,https://go.microsoft.com/fwlink/?LinkID=2109383
Update-TypeData,https://go.microsoft.com/fwlink/?LinkID=113421
Use-Transaction,https://go.microsoft.com/fwlink/?LinkID=135271
Wait-Event,https://go.microsoft.com/fwlink/?LinkID=135276
1 TopicTitle HelpURI
227 Unregister-Event https://go.microsoft.com/fwlink/?LinkID=135269
228 Unregister-PSSessionConfiguration https://go.microsoft.com/fwlink/?LinkID=144308
229 Update-FormatData https://go.microsoft.com/fwlink/?LinkID=113420
230 Update-List https://go.microsoft.com/fwlink/?LinkID=113447 https://go.microsoft.com/fwlink/?LinkID=2109383
231 Update-TypeData https://go.microsoft.com/fwlink/?LinkID=113421
232 Use-Transaction https://go.microsoft.com/fwlink/?LinkID=135271
233 Wait-Event https://go.microsoft.com/fwlink/?LinkID=135276