Title: Treating scalars implicitly as collections doesn't work with all objects - some lack a .Count property, as do some objects that are implicitly treated as collections · Issue #6456 · PowerShell/PowerShell · GitHub
Open Graph Title: Treating scalars implicitly as collections doesn't work with all objects - some lack a .Count property, as do some objects that are implicitly treated as collections · Issue #6456 · PowerShell/PowerShell
X Title: Treating scalars implicitly as collections doesn't work with all objects - some lack a .Count property, as do some objects that are implicitly treated as collections · Issue #6456 · PowerShell/PowerShell
Description: [Superseded by #6466] #3671 discussed the issue with respect to [pscustomobject] instances, for which a fix was attempted in #5756 (but the fix is not in v6.0.2 - Ilya (@iSazonov), should it be?). However, there are instances of other ty...
Open Graph Description: [Superseded by #6466] #3671 discussed the issue with respect to [pscustomobject] instances, for which a fix was attempted in #5756 (but the fix is not in v6.0.2 - Ilya (@iSazonov), should it be?). ...
X Description: [Superseded by #6466] #3671 discussed the issue with respect to [pscustomobject] instances, for which a fix was attempted in #5756 (but the fix is not in v6.0.2 - Ilya (@iSazonov), should it be?). ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6456
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Treating scalars implicitly as collections doesn't work with all objects - some lack a .Count property, as do some objects that are implicitly treated as collections","articleBody":"_[Superseded by #6466]_\r\n\r\n#3671 discussed the issue with respect to `[pscustomobject]` instances, for which a fix was attempted in #5756 (but the fix is not in v6.0.2 - @iSazonov, should it be?).\r\n\r\nHowever, there are instances of other types where the problem persists.\r\n\r\nIt would be good to clarity on the _generic_ issue, so that it can be fixed for _any_ (current and future) type.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n([System.Data.DataTable]::new()).Count\r\n([pscustomobject] @{}).Count\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\n0 # because [System.Data.DataTable] is treated as an *enumerable* - see @stknohg's comment below.\r\n1\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe output is `$null`, because there is no `.Count` property.\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-21T22:42:27Z","url":"https://github.com/PowerShell/PowerShell/issues/6456"}
| 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:5c9bd75e-c43f-c0f4-b8d7-d43b24985b98 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7A4:3A715F:B6495E:105072D:6AFDA6C9 |
| html-safe-nonce | e92e4ffaeaa179e73b13245929074881cce82eea61ad98fb7f3070bbcfb63a5a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0E0OjNBNzE1RjpCNjQ5NUU6MTA1MDcyRDo2QUZEQTZDOSIsInZpc2l0b3JfaWQiOiIyODEyNjAwMDY5MDUwNDQzNDY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 43c36ba93347f3f5f62488f7360d949d9ab9ca0ae22057fb219ac90cb7a3967c |
| hovercard-subject-tag | issue:307443778 |
| 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/6456/issue_layout |
| twitter:image | https://opengraph.githubassets.com/91994ec71c9cf3699a0a4926298a193b337e3646d01a5103f82efe80dc944722/PowerShell/PowerShell/issues/6456 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/91994ec71c9cf3699a0a4926298a193b337e3646d01a5103f82efe80dc944722/PowerShell/PowerShell/issues/6456 |
| og:image:alt | [Superseded by #6466] #3671 discussed the issue with respect to [pscustomobject] instances, for which a fix was attempted in #5756 (but the fix is not in v6.0.2 - Ilya (@iSazonov), should it be?). ... |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width