Title: Member enumeration unwraps and flattens array-valued properties · Issue #6454 · PowerShell/PowerShell · GitHub
Open Graph Title: Member enumeration unwraps and flattens array-valued properties · Issue #6454 · PowerShell/PowerShell
X Title: Member enumeration unwraps and flattens array-valued properties · Issue #6454 · PowerShell/PowerShell
Description: Note: The behavior described below has been in place since member enumeration was introduced in v3 and only affects array-valued properties. The behavior may well be by design, but given that it can be surprising, it may need to be docum...
Open Graph Description: Note: The behavior described below has been in place since member enumeration was introduced in v3 and only affects array-valued properties. The behavior may well be by design, but given that it ca...
X Description: Note: The behavior described below has been in place since member enumeration was introduced in v3 and only affects array-valued properties. The behavior may well be by design, but given that it ca...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6454
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Member enumeration unwraps and flattens array-valued properties","articleBody":"Note: \r\n* The behavior described below has been in place since [member enumeration](https://blogs.msdn.microsoft.com/powershell/2012/06/13/new-v3-language-features/) was introduced in v3 and only affects _array-valued_ properties.\r\n* The behavior may well be by design, but given that it can be surprising, it may need to be _documented_.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n# Create an object whose .prop value is an array of hashtables, only one of \r\n# which as a .subProp entry whose value is a single-element array, then\r\n# access .subProp via member enumeration.\r\n$obj=[pscustomobject] @{ prop = @{foo='foo'}, @{subProp=,1}}; ($obj.prop.subProp).GetType().Name\r\n\r\n# Create two 2-element arrays and let member enumeration collect them.\r\n$obj=[pscustomobject] @{prop = @{subProp=1,2}, @{subProp=3,4}}; $obj.prop.subProp.Count\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nInt32\r\n4\r\n```\r\n\r\nThe single-element array was _unwrapped_.\r\nThe two 2-element arrays were _concatenated_ (rather than collected as-is in a 2-element array).\r\n\r\n\r\nAlternative behavior\r\n-----------------\r\n\r\nOne _could_ expect the following behavior, and contrasting it with the actual behavior is worth documenting:\r\n\r\n```none\r\nObject[]\r\n2\r\n```\r\n\r\nThe value of the properties could have been passed through, just as with _direct_ property access (e.g., `$obj.prop[-1].subProp`):\r\n\r\n* In the first case: `, 1` may be expected, but `1` is returned.\r\n * Note that it's fine not to wrap `, 1` in an _outer_ array if only _one_ collection element's property value is found, because that is consistent with pipeline behavior.\r\n* In the second case: `(1, 2), (3, 4)` may be expected, but `1, 2, 3, 4` is returned (the equivalent of `(1, 2) + (3, 4)`)\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.2 on macOS 10.13.3\r\nPowerShell Core v6.0.2 on Ubuntu 16.04.3 LTS\r\nPowerShell Core v6.0.2 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\nWindows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-03-21T19:49:54Z","url":"https://github.com/PowerShell/PowerShell/issues/6454"}
| 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:6b99f705-9239-745f-e9d6-6c040713cd41 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8288:1D810A:C13020:116002D:6AFDA9E4 |
| html-safe-nonce | da1f4cf7041fb614bcf17068172ef60f5b03489a965bdabbfd85a0f464911a0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Mjg4OjFEODEwQTpDMTMwMjA6MTE2MDAyRDo2QUZEQTlFNCIsInZpc2l0b3JfaWQiOiI3NTcyNDQ4NDE0NjQ2Nzc0MjQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a2814297af9877f05845e8df934860bb23c7e47a3aba39af71c60197b21baeea |
| hovercard-subject-tag | issue:307393903 |
| 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/6454/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86f522aa17ff47cd7565c79e0f8469c477495378bcda2b9abeaddcf13013fcb6/PowerShell/PowerShell/issues/6454 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86f522aa17ff47cd7565c79e0f8469c477495378bcda2b9abeaddcf13013fcb6/PowerShell/PowerShell/issues/6454 |
| og:image:alt | Note: The behavior described below has been in place since member enumeration was introduced in v3 and only affects array-valued properties. The behavior may well be by design, but given that it ca... |
| 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 | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| 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 | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width