Skip to content

Commit a80acfd

Browse files
committed
Address review comments
1 parent 2d4cc7a commit a80acfd

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

docs/cmdlets/Get-OutputBinding.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gets the hashtable of the output bindings set so far.
1313
## SYNTAX
1414

1515
```
16-
Get-OutputBinding [-Name <String>] [-Purge] [<CommonParameters>]
16+
Get-OutputBinding [[-Name] <String>] [-Purge] [<CommonParameters>]
1717
```
1818

1919
## DESCRIPTION
@@ -54,10 +54,10 @@ Parameter Sets: (All)
5454
Aliases:
5555

5656
Required: False
57-
Position: Named
57+
Position: 0
5858
Default value: *
5959
Accept pipeline input: True (ByPropertyName, ByValue)
60-
Accept wildcard characters: True
60+
Accept wildcard characters: False
6161
```
6262
6363
### -Purge

docs/cmdlets/Trace-PipelineObject.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Writes the formatted output of the pipeline object to the information stream bef
1313
## SYNTAX
1414

1515
```
16-
Trace-PipelineObject -InputObject <Object> [<CommonParameters>]
16+
Trace-PipelineObject [-InputObject] <Object> [<CommonParameters>]
1717
```
1818

1919
## DESCRIPTION
@@ -40,7 +40,7 @@ Parameter Sets: (All)
4040
Aliases:
4141

4242
Required: True
43-
Position: Named
43+
Position: 0
4444
Default value: None
4545
Accept pipeline input: True (ByValue)
4646
Accept wildcard characters: False

src/Public/Commands/GetOutputBindingCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class GetOutputBindingCommand : PSCmdlet
3131
/// <summary>
3232
/// The name of the output binding you want to get. Supports wildcards.
3333
/// </summary>
34-
[Parameter(ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
34+
[Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
3535
[SupportsWildcards]
3636
[ValidateNotNullOrEmpty]
3737
public string Name { get; set; } = "*";

src/Public/Commands/TracePipelineObjectCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class TracePipelineObjectCommand : PSCmdlet
2828
/// <summary>
2929
/// The object from pipeline.
3030
/// </summary>
31-
[Parameter(Mandatory = true, ValueFromPipeline = true)]
31+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
3232
public object InputObject { get; set; }
3333

3434
private static PowerShell s_pwsh;

test/Unit/PowerShell/PowerShellManagerTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,31 @@ public void InvokeBasicFunctionWorks()
121121
}
122122
}
123123

124+
[Fact]
125+
public void InvokeFunctionWithSpecialVariableWorks()
126+
{
127+
string path = Path.Join(s_funcDirectory, "testBasicFunctionSpecialVariables.ps1");
128+
var (functionInfo, testManager) = PrepareFunction(path, string.Empty);
129+
130+
try
131+
{
132+
FunctionMetadata.RegisterFunctionMetadata(testManager.InstanceId, functionInfo);
133+
Hashtable result = testManager.InvokeFunction(functionInfo, null, s_testInputData);
134+
135+
// The outputBinding hashtable for the runspace should be cleared after 'InvokeFunction'
136+
Hashtable outputBindings = FunctionMetadata.GetOutputBindingHashtable(testManager.InstanceId);
137+
Assert.Empty(outputBindings);
138+
139+
// A PowerShell function should be created fro the Az function.
140+
string expectedResult = $"{s_funcDirectory},{path},{functionInfo.DeployedPSFuncName}";
141+
Assert.Equal(expectedResult, result[TestOutputBindingName]);
142+
}
143+
finally
144+
{
145+
FunctionMetadata.UnregisterFunctionMetadata(testManager.InstanceId);
146+
}
147+
}
148+
124149
[Fact]
125150
public void InvokeBasicFunctionWithRequiresWorks()
126151
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) Microsoft. All rights reserved.
3+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
#
5+
6+
param ($Req)
7+
8+
# Used for logging tests
9+
Write-Verbose "a log"
10+
$cmdName = $MyInvocation.MyCommand.Name
11+
12+
$result = "{0},{1},{2}" -f $PSScriptRoot, $PSCommandPath, $cmdName
13+
Push-OutputBinding -Name res -Value $result

0 commit comments

Comments
 (0)