Skip to content

Conversation

@brendandburns
Copy link
Contributor

PR Summary

Changes how the Write-Host cmdlet handles XMLElements, fixes #24508

PR Context

I'm not positive this is the right fix, spiritually I could get behind using .OuterXml instead which would print the whole XML document from that element, which seems aligned with the iteration of an Enumerable.

Either way, it is definitely the case that the current code doesn't work as expected.

PR Checklist

@brendandburns
Copy link
Contributor Author

brendandburns commented Dec 12, 2024

Let me know if you want me to update unit tests for this case.

Added a unit test.

@brendandburns
Copy link
Contributor Author

Another option would be to return enumerable.ToString() if the enumerable has zero elements in it (the case with XMLText) but that prints System.Xml.XmlText which I don't really think is the right output for Write-Host ([xml] '<OhElement>Where art thou?</OhElement>').DocumentElement

brendandburns and others added 2 commits December 13, 2024 07:06
…teConsoleCmdlet.cs

Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
…t.Tests.ps1

Co-authored-by: Steve Lee <slee@microsoft.com>
@daxian-dbw daxian-dbw merged commit 90b0149 into PowerShell:master Dec 13, 2024
37 checks passed
@jshigetomi jshigetomi added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write-Host renders an [xml] or [XmlElement] instance as an empty line.

5 participants