Title: An incidentally `[psobject]`-wrapped strongly typed array isn't recognized as such in argument-based parameter binding · Issue #21496 · PowerShell/PowerShell · GitHub
Open Graph Title: An incidentally `[psobject]`-wrapped strongly typed array isn't recognized as such in argument-based parameter binding · Issue #21496 · PowerShell/PowerShell
X Title: An incidentally `[psobject]`-wrapped strongly typed array isn't recognized as such in argument-based parameter binding · Issue #21496 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/21496
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"An incidentally `[psobject]`-wrapped strongly typed array isn't recognized as such in argument-based parameter binding","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nNote:\r\n* This is yet another manifestation of #5579\r\n\r\n```powershell\r\n# Create and import a sample cmdlet that requires [byte[]] input\r\nAdd-Type @'\r\nusing System.Management.Automation;\r\n[Cmdlet(\"Get\", \"Foo\")]\r\npublic class GetFooCommand : PSCmdlet\r\n{\r\n [Parameter(Mandatory=true,ValueFromPipeline=true)]\r\n public byte[] InputObject;\r\n\r\n protected override void ProcessRecord()\r\n {\r\n }\r\n}\r\n'@ -PassThru | ForEach-Object Assembly | Import-Module\r\n\r\n# Create two instances of a large byte array, one without and\r\n# one with a [psobject] wrapper\r\n$byteArrayUnwrapped = [byte[]]::new(64mb)\r\n$byteArrayWrapped = New-Object byte[] 64mb # equivalent, but with implicit [psobject] wrapper\r\n\r\n'--- unwrapped'\r\nGet-Foo -InputObject $byteArrayUnwrapped\r\n'--- wrapped'\r\nGet-Foo -InputObject $byteArrayWrapped # !! Excessively slow.\r\n'--- done'\r\n```\r\n\r\nNote that parameter binding _via the pipeline_ is _not_ affected; that is, \r\n`, $byteArrayWrapped | Get-Foo` works as intended (note the need to wrap `$byteArrayWrapped` in an aux., transitory array via the unary form of `,` so as to ensure that it is passed as a _single object_).\r\n\r\n### Expected behavior\r\n\r\nBoth calls should return virtually instantly, given that the argument type exactly matches the parameter type and that the cmdlet is otherwise a no-op.\r\n\r\n### Actual behavior\r\n\r\nThe second call, due to the invisible `[psobject]` wrapper resulting from use of `New-Object` to construct the array, takes an excessive amount of time to complete.\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell 7.5.0-preview.2\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2024-04-17T20:38:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/21496/PowerShell/issues/21496"}
| 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:82f2edb5-d23c-3d61-0d4c-8c4feeaa91a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A122:236045:3F8EE9:54E24C:6A5B2707 |
| html-safe-nonce | 0bb12be16a093ccd1e1ae9a1539b5105f68c20e2bed7cdbeeec1f4d3b90d6ce7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTIyOjIzNjA0NTozRjhFRTk6NTRFMjRDOjZBNUIyNzA3IiwidmlzaXRvcl9pZCI6IjI5NzU5MDI4NTE3MTE4Mzc5NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6f7cc05ef17302377de363d0763a9106ce7e6c884de9c0dbdad1d4fb907cf1e0 |
| hovercard-subject-tag | issue:2249231267 |
| 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/21496/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e13efbcf811b14118f68d9b38d3dd4562f5343ea5ea331a61674f25d134c5611/PowerShell/PowerShell/issues/21496 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e13efbcf811b14118f68d9b38d3dd4562f5343ea5ea331a61674f25d134c5611/PowerShell/PowerShell/issues/21496 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| 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 | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width