Support PSObject wrapped values in ArgumentToEncodingTransformationAttribute (#24555)

This commit is contained in:
Jordan Borean 2024-11-12 13:41:22 +10:00 committed by GitHub
parent 31b70ecd9f
commit ba238808fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -115,6 +115,8 @@ namespace System.Management.Automation
{
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
{
inputData = PSObject.Base(inputData);
switch (inputData)
{
case string stringName:

View File

@ -89,6 +89,8 @@ Describe "File encoding tests" -Tag CI {
It "Parameter 'Encoding' should accept '<encoding>'" -TestCases @(
@{ encoding = 1251 }
@{ encoding = "windows-1251" }
# Piping the string creates a PSObject boxed value that we are testing.
@{ encoding = ("windows-1251" | Write-Output) }
) {
param ( $encoding )
$testFile = "${TESTDRIVE}/fileEncoding-$($encoding).txt"