René's URL Explorer Experiment


Title: Collection operators .Where() and .ForEach() do not unwrap single-item results · Issue #6512 · PowerShell/PowerShell · GitHub

Open Graph Title: Collection operators .Where() and .ForEach() do not unwrap single-item results · Issue #6512 · PowerShell/PowerShell

X Title: Collection operators .Where() and .ForEach() do not unwrap single-item results · Issue #6512 · PowerShell/PowerShell

Description: The PSv4+ collection operators .Where() and .ForEach() differ from normal pipeline-output collecting behavior in two respects: If the result is a single item, it isn't unwrapped; that is, a collection is always returned, and that collect...

Open Graph Description: The PSv4+ collection operators .Where() and .ForEach() differ from normal pipeline-output collecting behavior in two respects: If the result is a single item, it isn't unwrapped; that is, a collect...

X Description: The PSv4+ collection operators .Where() and .ForEach() differ from normal pipeline-output collecting behavior in two respects: If the result is a single item, it isn't unwrapped; that is, a col...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6512

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Collection operators .Where() and .ForEach() do not unwrap single-item results","articleBody":"The PSv4+ collection operators `.Where()` and `.ForEach()` differ from normal pipeline-output collecting behavior in two respects:\r\n\r\n* If the result is a _single_ item, it _isn't unwrapped_; that is, a _collection_ is _always_ returned, and\r\n* that collection is always of type `[System.Collections.ObjectModel.Collection[psobject]]` rather than a regular PS array (`[object[]]`)\r\n\r\nIn the spirit of https://github.com/PowerShell/PowerShell-RFC/pull/120, the **behavior should be harmonized with how pipeline output is already collected and how the `-*Variable` common parameters (except `-PipelineVariable`) _should_ collect output, according to the RFC**.\r\n\r\nGiven how contentious the linked `-OutVariable`-related RFC is turning out to be, this proposal may need to become an RFC as well, though perhaps the decision on said RFC will imply how to proceed here.\r\n\r\nTo reiterate what, to me, motivates this desire for harmonization / resolving inconsistencies:\r\n\r\n**The unifying vision is to provide a consistent experience whenever PowerShell collects output for you**, so you never need to worry about different unwrapping  behavior and/or differing collection types.\r\n\r\nNote:\r\n\r\n**This harmonization would currently incur a performance cost**, because the internally used, resizable collection data types must on output be converted to `object[]]`.\r\n\r\nHowever, **the proper way to resolve this is to switch PowerShell's fundamental collection data type from `[object[]]` to an _efficiently resizable_ one that can be used internally _and_ directly output.**\r\n[Discussion in that direction has started](https://github.com/PowerShell/PowerShell/issues/5643#issuecomment-349811857), but it's obviously a massive _internal_ change; _externally_, assuming no bugs have crept in, however, much of existing code may not only continue to work as-is, but may exhibit automatic performance gains.\r\n\r\nTo quote @lzybkr  from the linked issue:\r\n\r\n> I've often wondered if the comma operator could create a list instead of an array. I have a feeling most scripts would never notice a difference because of how freely things are converted to an object array.\r\n\r\nCurrent Behavior\r\n-----------------\r\n\r\n```powershell\r\nPS> (1).ForEach({$_}).GetType().Name; (1, 2).ForEach({$_}).GetType().Name\r\nCollection`1  # single-item result wasn't unwrapped\r\nCollection`1  # output collection type is not [object[]]\r\n```\r\n\r\nDesired Behavior\r\n-----------------\r\n\r\n```powershell\r\nPS> (1).ForEach({$_}).GetType().Name; (1, 2).ForEach({$_}).GetType().Name\r\nInt32      # single-item result was unwrapped\r\nObject[]   # regular PS array\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-03-27T18:03:17Z","url":"https://github.com/PowerShell/PowerShell/issues/6512"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f76a86d6-241d-cbb2-ef7a-1b36469931d3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA8E:24FA16:77BF7:A32AF:6AFD8AB3
html-safe-nonce8a408911ed56ad569a7134a896c3f0d1699c4041e1671160c2e163efe7843f98
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQThFOjI0RkExNjo3N0JGNzpBMzJBRjo2QUZEOEFCMyIsInZpc2l0b3JfaWQiOiI2Njc1Njk5NTExODMwNDczNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac332481ef529391c6270abeba8450797a8935caa80a3bd90ab922a73ae0d9b59b
hovercard-subject-tagissue:309074479
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/6512/issue_layout
twitter:imagehttps://opengraph.githubassets.com/eb13830c7f5a3b9816422e413af86d7c69cbf0f7d9ab9986b68a2b169aa7f85a/PowerShell/PowerShell/issues/6512
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/eb13830c7f5a3b9816422e413af86d7c69cbf0f7d9ab9986b68a2b169aa7f85a/PowerShell/PowerShell/issues/6512
og:image:altThe PSv4+ collection operators .Where() and .ForEach() differ from normal pipeline-output collecting behavior in two respects: If the result is a single item, it isn't unwrapped; that is, a collect...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
Nonebc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/6512#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F6512
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F6512
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/6512
Reloadhttps://github.com/PowerShell/PowerShell/issues/6512
Reloadhttps://github.com/PowerShell/PowerShell/issues/6512
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests366 (366)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6512
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6512
Collection operators .Where() and .ForEach() do not unwrap single-item resultshttps://github.com/PowerShell/PowerShell/issues/6512#top
Resolution-By DesignThe reported behavior is by design.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-By%20Design%22
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#issue-309074479
PowerShell/PowerShell-RFC#120https://github.com/PowerShell/PowerShell-RFC/pull/120
Discussion in that direction has startedhttps://github.com/PowerShell/PowerShell/issues/5643#issuecomment-349811857
Jason Shirk (@lzybkr)https://github.com/lzybkr
https://github.com/BrucePay
Bruce Payette (BrucePay)https://github.com/BrucePay
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-376628748
Michael Klement (@mklement0)https://github.com/mklement0
Bruce Payette (BrucePay)https://github.com/BrucePay
Resolution-By DesignThe reported behavior is by design.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-By%20Design%22
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#event-1543932923
Bruce Payette (BrucePay)https://github.com/BrucePay
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#event-1543933089
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-376631585
Bruce Payette (@BrucePay)https://github.com/BrucePay
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
https://github.com/BrucePay
Bruce Payette (BrucePay)https://github.com/BrucePay
on Mar 27, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-376699115
Michael Klement (@mklement0)https://github.com/mklement0
Steve Lee (SteveL-MSFT)https://github.com/SteveL-MSFT
Documentation Needed in this repoDocumentation is needed in this repohttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Documentation%20Needed%20in%20this%20repo%22
on Mar 28, 2018https://github.com/PowerShell/PowerShell/issues/6512#event-1544518092
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Mar 28, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-376738923
at least internally terming them operatorshttps://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs#L2427
"Where() operator behavior has changed."https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/Where-Object?view=powershell-6#notes
https://github.com/BrucePay
Bruce Payette (BrucePay)https://github.com/BrucePay
on Mar 28, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-377072126
Using configuration data in DSChttps://docs.microsoft.com/en-us/powershell/dsc/configdata
Separating configuration and environment datahttps://docs.microsoft.com/en-us/powershell/dsc/separatingenvdata
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Apr 4, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-378474445
herehttp://www.powershellmagazine.com/2014/10/22/foreach-and-where-magic-methods/
Kirk Munro (@KirkMunro)https://github.com/KirkMunro
Why is [pscustomobject] the same as [psobject], even though a distinct [System.Management.Automation.PSCustomObject] type exists? #4344https://github.com/PowerShell/PowerShell/issues/4344
-as operator does not recognize System.Management.Automation.PSCustomObject instances as such #4343https://github.com/PowerShell/PowerShell/issues/4343
Objects are situationally invisibly [psobject]-wrapped, sometimes causing unexpected behavior. #5579https://github.com/PowerShell/PowerShell/issues/5579
Preference variable $OutputEncoding in child scopes misbehaves with encodings created with New-Object / commands rather than expressions #5763https://github.com/PowerShell/PowerShell/issues/5763
ConvertTo-Json: unexpected behavior with objects that have ETS properties (NoteProperty, ScriptProperty) #5797https://github.com/PowerShell/PowerShell/issues/5797
as I've tried to argue herehttps://github.com/PowerShell/PowerShell/issues/5805#issuecomment-366811092
discussion of fundamentally changing PowerShell's collection data typehttps://github.com/PowerShell/PowerShell/issues/5643#issuecomment-378467986
https://github.com/KirkMunro
Kirk Munro (KirkMunro)https://github.com/KirkMunro
on Apr 4, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-378693901
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Apr 4, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-378698677
Kirk Munro (@KirkMunro)https://github.com/KirkMunro
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Apr 5, 2018https://github.com/PowerShell/PowerShell/issues/6512#issuecomment-379060894
#6576https://github.com/PowerShell/PowerShell/issues/6576
Joey Aiello (joeyaiello)https://github.com/joeyaiello
Documentation Needed in this repoDocumentation is needed in this repohttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Documentation%20Needed%20in%20this%20repo%22
on Oct 15, 2018https://github.com/PowerShell/PowerShell/issues/6512#event-1905293990
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/6512
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6512
Resolution-By DesignThe reported behavior is by design.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-By%20Design%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.