Prerequisites
Steps to reproduce
Write-Host ([xml] '<OhElement>Where art thou?</OhElement>').DocumentElement
Note: The problem may come down to the base class, System.Xml.XmlNode, implementing IEnumerable, and Write-Host not only enumerating the given instance itself, but doing so recursively, down to the leaf elements that by definition have nothing to enumerate. As argued below, no enumeration should take place at all.
Expected behavior
i.e., the name of the element, as if you had applied .ToString() to the instance.
Note that even though such instances technically implement IEnumerable, for consistency with pipeline enumeration behavior I expect them not to be enumerated.
I suspect that the bug is related to the fact that they are enumerated.
Actual behavior
Error details
No response
Environment data
PowerShell 7.5.0-preview.5 (problem dates back to Windows PowerShell)
Visuals
No response
Prerequisites
Steps to reproduce
Note: The problem may come down to the base class,
System.Xml.XmlNode, implementingIEnumerable, andWrite-Hostnot only enumerating the given instance itself, but doing so recursively, down to the leaf elements that by definition have nothing to enumerate. As argued below, no enumeration should take place at all.Expected behavior
OhElementi.e., the name of the element, as if you had applied
.ToString()to the instance.Note that even though such instances technically implement
IEnumerable, for consistency with pipeline enumeration behavior I expect them not to be enumerated.I suspect that the bug is related to the fact that they are enumerated.
Actual behavior
(An empty line prints.)Error details
No response
Environment data
Visuals
No response