Skip to content

Conversation

@brendandburns
Copy link
Contributor

PR Summary

Fix Write-Host to consistently serialize using ToString, fixed #24671

PR Context

In the fixing of a bug related to XMLNode, IDictionary was also called out as an example of inconsistency. Following discussion in #24669 this code was also refactored to use switch instead of if .. else

PR Checklist

@daxian-dbw
Copy link
Member

This PR will change the current way of rendering for Write-Host $dictionary, which is a behavior change. We will need the "Cmdlet Working Group" to review #24671 and decide what behavior change is desired.

@daxian-dbw daxian-dbw added the WG-NeedsReview Needs a review by the labeled Working Group label Dec 13, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Dec 20, 2024
@{ Name = '-NoNewline:$true and colors'; Command = "Write-Host a,b -NoNewline:`$true -ForegroundColor Red -BackgroundColor Green;Write-Host a,b"; returnCount = 2; returnValue = @("Red:Green:a b:NoNewLine", "White:Black:a b:NewLine"); returnInfo = @("a b", "a b") }
@{ Name = '-NoNewline:$false and colors'; Command = "Write-Host a,b -NoNewline:`$false -ForegroundColor Red -BackgroundColor Green;Write-Host a,b"; returnCount = 2; returnValue = @("Red:Green:a b:NewLine","White:Black:a b:NewLine"); returnInfo = @("a b", "a b") }
@{ Name = 'XMLElement'; Command = "Write-Host ([xml] '<OhElement>Where art thou?</OhElement>').DocumentElement"; returnCount = 1; returnValue = @("White:Black:OhElement:NewLine"); returnInfo = @("OhElement") }
@{ Name = 'XMLDocument'; Command = "Write-Host ([system.xml.xmldocument] '<OhElement>Where art thou?</OhElement>').DocumentElement"; returnCount = 1; returnValue = @("White:Black:OhElement:NewLine"); returnInfo = @("OhElement") }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a duplicate of this one.

@SteveL-MSFT SteveL-MSFT added the WG-Cmdlets general cmdlet issues label Jan 15, 2025
@SteveL-MSFT
Copy link
Member

The @PowerShell/wg-powershell-cmdlets reviewed this and we agree that this PR addresses an inconsistent behavior with Write-Host and IDictionary objects to be consistent with other IEnumerable types where the current behavior of emitting the type information is not useful.

@SteveL-MSFT SteveL-MSFT added WG-Reviewed A Working Group has reviewed this and made a recommendation and removed WG-NeedsReview Needs a review by the labeled Working Group labels Jan 15, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Jan 15, 2025
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed WG-Cmdlets general cmdlet issues WG-Reviewed A Working Group has reviewed this and made a recommendation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants