-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix Write-Host for IDictionary objects #24676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This PR will change the current way of rendering for |
| @{ 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") } |
There was a problem hiding this comment.
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.
|
The @PowerShell/wg-powershell-cmdlets reviewed this and we agree that this PR addresses an inconsistent behavior with |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
Fix Write-Host to consistently serialize using
ToString, fixed #24671PR 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
switchinstead ofif .. elsePR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).