10000 Support PSObject wrapped values in ArgumentToEncodingTransformationAt… · awakecoding/PowerShell@ba23880 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba23880

Browse files
authored
Support PSObject wrapped values in ArgumentToEncodingTransformationAttribute (PowerShell#24555)
1 parent 31b70ec commit ba23880

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/System.Management.Automation/utils/EncodingUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ internal sealed class ArgumentToEncodingTransformationAttribute : ArgumentTransf
115115
{
116116
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
117117
{
118+
inputData = PSObject.Base(inputData);
119+
118120
switch (inputData)
119121
{
120122
case string stringName:

test/powershell/engine/Basic/Encoding.Tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Describe "File encoding tests" -Tag CI {
8989
It "Parameter 'Encoding' should accept '<encoding>'" -TestCases @(
9090
@{ encoding = 1251 }
9191
@{ encoding = "windows-1251" }
92+
# Piping the string creates a PSObject boxed value that we are testing.
93+
@{ encoding = ("windows-1251" | Write-Output) }
9294
) {
9395
param ( $encoding )
9496
$testFile = "${TESTDRIVE}/fileEncoding-$($encoding).txt"

0 commit comments

Comments
 (0)
0