Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

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

OhElement

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

(An empty line prints.)

Error details

No response

Environment data

PowerShell 7.5.0-preview.5 (problem dates back to Windows PowerShell)

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.