Skip to content

Write-Host renders IDictionary inconsistently depending on if the value is piped in #24671

@daxian-dbw

Description

@daxian-dbw

Prerequisites

Steps to reproduce

Write-Host renders an instance of Dictionary inconsistently depending on how the value is passed in: Write-Host $d vs. $d | Write-Host.

$d = [System.Collections.Generic.Dictionary[string,string]]::new()
$d.Add('abc', 'def')
$d.Add('hhh', 'nnn')

Write-Host $d
> [abc, def] [hhh, nnn]

$d | Write-Host
> System.Collections.Generic.Dictionary`2[System.String,System.String]

Expected behavior

The rendering result should be consistent.

Actual behavior

## Not consistent.

Write-Host $d
> [abc, def] [hhh, nnn]

$d | Write-Host
> System.Collections.Generic.Dictionary`2[System.String,System.String]

Error details

N/A

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.6
PSEdition                      Core
GitCommitId                    7.4.6
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions