Add 'Path' alias to '-FilePath' parameters and others for several commands (#5817)

This commit is contained in:
Kevin Marquette 2018-02-27 13:05:58 -08:00 committed by Dongbo Wang
parent e95f0099ed
commit 548850d249
14 changed files with 35 additions and 4 deletions

View File

@ -1607,7 +1607,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter(Mandatory = true, Position = 0)]
[ValidateNotNullOrEmpty]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath { get; set; }
/// <summary>

View File

@ -1897,6 +1897,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
/// <value></value>
[Parameter(Position = 1, Mandatory = true)]
[Alias("Path")]
public string BinaryPathName
{
get { return binaryPathName; }

View File

@ -28,6 +28,7 @@ namespace Microsoft.PowerShell.Commands
/// FilePath parameter
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = "File")]
[Alias("Path")]
public string FilePath
{
get { return _fileName; }

View File

@ -62,7 +62,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
/// <value></value>
[Parameter(ParameterSetName = "optionsSet")]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath
{
get { return base.FileListener; }

View File

@ -96,7 +96,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
/// <value></value>
[Parameter]
[Alias("PSPath")]
[Alias("PSPath","Path")]
public string FilePath
{
get { return base.FileListener; }

View File

@ -31,6 +31,7 @@ namespace Microsoft.PowerShell.ScheduledJob
/// </summary>
[Parameter(Position = 1, Mandatory = true,
ParameterSetName = RegisterScheduledJobCommand.FilePathParameterSet)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{

View File

@ -42,6 +42,7 @@ namespace Microsoft.PowerShell.ScheduledJob
/// File path for script to be run in job.
/// </summary>
[Parameter(ParameterSetName = SetScheduledJobCommand.FilePathParameterSet)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{

View File

@ -101,6 +101,7 @@ namespace Microsoft.WSMan.Management
/// via this input file
/// </summary>
[Parameter]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public String FilePath
{

View File

@ -674,6 +674,7 @@ namespace Microsoft.WSMan.Management
/// via this input file
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Path")]
[ValidateNotNullOrEmpty]
public string FilePath
{
@ -1258,6 +1259,7 @@ namespace Microsoft.WSMan.Management
/// </summary>
[Parameter]
[ValidateNotNullOrEmpty]
[Alias("Path")]
public String FilePath
{
get { return filepath; }

View File

@ -41,6 +41,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = PathParameterSetName)]
[ValidateNotNull]
[Alias("Path")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] DestinationPath
{

View File

@ -71,6 +71,7 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
[Parameter(Position = 1, ParameterSetName = PathParameterSetName)]
[ValidateNotNull]
[Alias("Path")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] SourcePath
{

View File

@ -46,6 +46,13 @@ Describe "Start-Process" -Tags @("Feature") {
# $process.ProcessName | Should Be "ping"
}
It "Should invoke correct path when used with Path alias argument" {
$process = Start-Process -Path $pingCommand -ArgumentList $pingParam -PassThru -RedirectStandardOutput "$TESTDRIVE/output"
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
}
It "Should wait for command completion if used with Wait argument" {
$process = Start-Process ping -ArgumentList $pingParam -Wait -PassThru -RedirectStandardOutput "$TESTDRIVE/output"
}
@ -110,7 +117,7 @@ Describe "Start-Process" -Tags @("Feature") {
It "Should be able to use the -WhatIf switch without performing the actual action" {
$pingOutput = Join-Path $TestDrive "pingOutput.txt"
{ Start-Process -Wait $pingCommand -ArgumentList $pingParam -RedirectStandardOutput $pingOutput -WhatIf -ErrorAction Stop } | Should Not Throw
$pingOutput | Should Not Exist
$pingOutput | Should Not Exist
}
It "Should return null when using -WhatIf switch with -PassThru" {

View File

@ -35,6 +35,15 @@ Describe "Tee-Object DRT Unit Tests" -Tags "CI" {
$content | Should Be $expected
}
It "Positive File Test with Path parameter alias" {
$expected = "1", "2", "3"
$results = $expected | Tee-Object -Path $tempFile
$results.Length | Should be 3
$results | Should Be $expected
$content = Get-Content $tempFile
$content | Should Be $expected
}
It "Positive Variable Test" {
$expected = "1", "2", "3"
$varName = "teeObjectTestVar"

View File

@ -119,6 +119,12 @@ Describe "Trace-Command" -tags "CI" {
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
}
It "Trace-Command using Path parameter alias" {
$null = New-Item $filePath -Force
Trace-Command -Name ParameterBinding -Command 'Get-PSDrive' -Path $filePath -Force
Get-Content $filePath -Raw | Should Match 'ParameterBinding Information'
}
It "Trace-Command contains wildcard characters" {
$a = Trace-Command -Name ParameterB* -Command 'get-alias'
$a.count | Should BeGreaterThan 0