Skip to content

about_Pipelines should explain the pipeline's enumeration behavior in more detail #3285

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

Closed
6 tasks done
mklement0 opened this issue Nov 14, 2018 · 1 comment
Closed
6 tasks done
Assignees
Labels
area-engine Area - PowerShell engine

Comments

@mklement0
Copy link
Contributor

A core feature of the pipeline is to enumerate collection-like data structures.

The One-At-A-Time Processing section of about_Pipelines touches on that, but could use some more detail, notably with respect to what specific data types are considered collections and are therefore enumerated (sent through the pipeline one by one).

From what I gather, the rules are:

  • Instances of data types that implement the IEnumerable interface are automatically enumerated, but there are exceptions:
    • Types that also implement IDictionary, such as hashtables, are not enumerated, and neither are XmlNode instances.
  • Conversely, instances of DataTable (which doesn't implement IEnumerable) are enumerated (as the elements of their .Rows collection)

See the source code.

If that is considered too detailed / technical, it's at least worth mentioning that [hashtable] instances are not enumerated by default, and that doing so requires a call to .GetEnumerator() (a fact that already is mentioned in the hash-table-specific topic, about_Hash_Tables).

Additionally it's worth mentioning that (stdout) output from external programs is enumerated line by line in the pipeline.

Version(s) of document impacted

  • Impacts 6.next document
  • Impacts 6 document
  • Impacts 5.1 document
  • Impacts 5.0 document
  • Impacts 4.0 document
  • Impacts 3.0 document
@sdwheeler sdwheeler added Reference area-engine Area - PowerShell engine labels Nov 14, 2018
@Halkcyon
Copy link

I feel like many of these details are addressed in other articles on those specific items inadvertently, but it would be nice to see them in a single location when talking about the pipeline to redirect newer users to learn as suggested by this request.

@bobbytreed bobbytreed self-assigned this May 9, 2019
@bobbytreed bobbytreed added the review-shiproom Waiting - for Shiproom discussion label May 10, 2019
bobbytreed added a commit to bobbytreed/PowerShell-Docs that referenced this issue May 30, 2019
…explain automatic collection enumeration
@sdwheeler sdwheeler removed review-shiproom Waiting - for Shiproom discussion labels May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-engine Area - PowerShell engine
Projects
None yet
Development

No branches or pull requests

4 participants