Title: Common parameters -OutVariable, -ErrorVariable, -WarningVariable, and -InformationVariable always return a [System.Collections.ArrayList] instance, even with a single object · Issue #3773 · PowerShell/PowerShell · GitHub
Open Graph Title: Common parameters -OutVariable, -ErrorVariable, -WarningVariable, and -InformationVariable always return a [System.Collections.ArrayList] instance, even with a single object · Issue #3773 · PowerShell/PowerShell
X Title: Common parameters -OutVariable, -ErrorVariable, -WarningVariable, and -InformationVariable always return a [System.Collections.ArrayList] instance, even with a single object · Issue #3773 · PowerShell/PowerShell
Description: Note: The problem was first discovered with -OutVariable - see #3154. The problem applies to all -*Variable common parameters, however, with the exception of -PipelineVariable (which inherently captures a single item at time). To recap t...
Open Graph Description: Note: The problem was first discovered with -OutVariable - see #3154. The problem applies to all -*Variable common parameters, however, with the exception of -PipelineVariable (which inherently cap...
X Description: Note: The problem was first discovered with -OutVariable - see #3154. The problem applies to all -*Variable common parameters, however, with the exception of -PipelineVariable (which inherently cap...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3773
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Common parameters -OutVariable, -ErrorVariable, -WarningVariable, and -InformationVariable always return a [System.Collections.ArrayList] instance, even with a single object","articleBody":"Note: The problem was first discovered with `-OutVariable` - see #3154. \r\nThe problem applies to all `-*Variable` common parameters, however, with the exception of `-PipelineVariable` (which inherently captures a _single_ item at time).\r\n\r\nTo recap the problem:\r\n\r\n* Even if only a _single_ value is captured by these parameters, an _array list_ rather than a scalar is returned (the single-element collection isn't unwrapped - a deviation from PowerShell's normal collection handling).\r\n\r\n* Also - another deviation from usual PowerShell behavior - it is type `[System.Collections.ArrayList]` that is always used, in contrast with the `[System.Object[]]` instances you get with _regular_ assignments.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n# Adv. function that outputs a single item of each type.\r\nfunction foo {\r\n [CmdletBinding()]\r\n param()\r\n \r\n Write-Warning 'warn'\r\n Write-Information 'info'\r\n Write-Error 'err'\r\n 'out'\r\n}\r\n\r\nfoo -OutVariable ov -ErrorVariable ev -WarningVariable wv -InformationVariable iv *>$null\r\n\r\n$ov, $ev, $wv, $iv | % GetType | % Name\r\n```\r\n\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```\r\nString\r\nErrorRecord\r\nWarningRecord\r\nInformationRecord\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```\r\nArrayList\r\nArrayList\r\nArrayList\r\nArrayList\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta (v6.0.0-beta.1)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-05-12T14:39:00Z","url":"https://github.com/PowerShell/PowerShell/issues/3773"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:75d3a610-ab1d-cbf2-06d9-5c9eeac43a65 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8570:993EB:1E6D8D:29F80E:6AFD806D |
| html-safe-nonce | 40bdd3a484c184844580702dd722969d1c753f12b0cc530ce94e6630c6045a20 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTcwOjk5M0VCOjFFNkQ4RDoyOUY4MEU6NkFGRDgwNkQiLCJ2aXNpdG9yX2lkIjoiNjMwMDM5MTY5NzQwOTMxMTgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 666bde102ea6a631c01f8f123157171e91c3c14afe6ca62bddd827c33cd8bd2d |
| hovercard-subject-tag | issue:228312350 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3773/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2258a31629e7112bb9ea6b1e5f8b8f3a11b5b1faf7c60d224c16165387ffda7/PowerShell/PowerShell/issues/3773 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2258a31629e7112bb9ea6b1e5f8b8f3a11b5b1faf7c60d224c16165387ffda7/PowerShell/PowerShell/issues/3773 |
| og:image:alt | Note: The problem was first discovered with -OutVariable - see #3154. The problem applies to all -*Variable common parameters, however, with the exception of -PipelineVariable (which inherently cap... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42d4967e3c8afca51ccac31f419a705af777226a95f025ea73387d87a306b326 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2329ceed0bc2c7b7c3b9f5f2db6abfc7b6fc3a50 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width