Title: Write-Output $null -NoEnumerate produces different Collection
Open Graph Title: Write-Output $null -NoEnumerate produces different Collection
X Title: Write-Output $null -NoEnumerate produces different Collection
Description: I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why. Steps to reproduce $r = [System.Collections.ObjectModel.Collection[psobjec...
Open Graph Description: I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why. Steps to reproduce $r = [System.Co...
X Description: I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why. Steps to reproduce $r = [Syste...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6451
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Write-Output $null -NoEnumerate produces different Collection\u003cPSObject> in 5.1 vs 6.0","articleBody":"I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$r = [System.Collections.ObjectModel.Collection[psobject]]{Write-Output $null -NoEnumerate}.Invoke()\r\n$r.item(0).GetType()\r\n```\r\n\r\nBehavior in PowerShell 5.1\r\n-----------------\r\n\r\n```none\r\nYou cannot call a method on a null-valued expression.\r\nAt C:\\Users\\un1\\Desktop\\test.ps1:2 char:1\r\n+ $r[0].GetType()\r\n+ ~~~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidOperation: (:) [], RuntimeException\r\n + FullyQualifiedErrorId : InvokeMethodOnNull\r\n```\r\n\r\n```PowerShell\r\n>$PSVersionTable\r\n\r\nName Value \r\n---- ----- \r\nPSVersion 5.1.14409.1012 \r\nPSEdition Desktop \r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} \r\nBuildVersion 10.0.14409.1012 \r\nCLRVersion 4.0.30319.42000 \r\nWSManStackVersion 3.0 \r\nPSRemotingProtocolVersion 2.3 \r\nSerializationVersion 1.1.0.1 \r\n```\r\n\r\nBehavior in PowerShell 6.0\r\n---------------\r\n\r\n```none\r\nIsPublic IsSerial Name BaseType\r\n-------- -------- ---- --------\r\nTrue True PSObject[] System.Array\r\n```\r\n\r\n```powershell\r\n> $PSVersionTable\r\n\r\nName Value \r\n---- ----- \r\nPSVersion 6.0.2 \r\nPSEdition Core \r\nGitCommitId v6.0.2 \r\nOS Microsoft Windows 6.3.9600 \r\nPlatform Win32NT \r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} \r\nPSRemotingProtocolVersion 2.3 \r\nSerializationVersion 1.1.0.1 \r\nWSManStackVersion 3.0 \r\n```\r\n\r\n","author":{"url":"https://github.com/alx9r","@type":"Person","name":"alx9r"},"datePublished":"2018-03-21T17:49:25Z","url":"https://github.com/PowerShell/PowerShell/issues/6451"}
| 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:4146b8e1-eec0-4f4c-2edf-1022bdeaf9aa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A2E8:2BF055:DE8B5:13C141:6AFD5C93 |
| html-safe-nonce | ab58af435d6aa24187df952871bc65ee0db19c319fe920f36bc75d82d9c54d68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkU4OjJCRjA1NTpERThCNToxM0MxNDE6NkFGRDVDOTMiLCJ2aXNpdG9yX2lkIjoiNDQzODA2ODM1ODE5MjkxMzU1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1b5e43d585367aa0f0889a1d4ad1439593e86480ee7c50a857f882508f054071 |
| hovercard-subject-tag | issue:307353139 |
| 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/6451/issue_layout |
| twitter:image | https://opengraph.githubassets.com/108c9e7a238092ffc2550074f533d9bbbaab52e45f4ac805ba4e8c2d045d1094/PowerShell/PowerShell/issues/6451 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/108c9e7a238092ffc2550074f533d9bbbaab52e45f4ac805ba4e8c2d045d1094/PowerShell/PowerShell/issues/6451 |
| og:image:alt | I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why. Steps to reproduce $r = [System.Co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alx9r |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width