Title: PowerShell class defined in 'New-Module -ScriptBlock' doesn't work as expected · Issue #2841 · PowerShell/PowerShell · GitHub
Open Graph Title: PowerShell class defined in 'New-Module -ScriptBlock' doesn't work as expected · Issue #2841 · PowerShell/PowerShell
X Title: PowerShell class defined in 'New-Module -ScriptBlock' doesn't work as expected · Issue #2841 · PowerShell/PowerShell
Description: Steps to reproduce New-Module -Name ReloadingTest -ScriptBlock { $passedArgs = $args class Root { $passedIn = $passedArgs } function Get-PassedArgsRoot { [Root]::new().passedIn } function Get-PassedArgsNoRoot { $passedArgs } } -ArgumentL...
Open Graph Description: Steps to reproduce New-Module -Name ReloadingTest -ScriptBlock { $passedArgs = $args class Root { $passedIn = $passedArgs } function Get-PassedArgsRoot { [Root]::new().passedIn } function Get-Passe...
X Description: Steps to reproduce New-Module -Name ReloadingTest -ScriptBlock { $passedArgs = $args class Root { $passedIn = $passedArgs } function Get-PassedArgsRoot { [Root]::new().passedIn } function Get-Passe...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/2841
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PowerShell class defined in 'New-Module -ScriptBlock' doesn't work as expected","articleBody":"Steps to reproduce\r\n------------------\r\n```\r\nNew-Module -Name ReloadingTest -ScriptBlock {\r\n $passedArgs = $args\r\n class Root { $passedIn = $passedArgs }\r\n function Get-PassedArgsRoot { [Root]::new().passedIn }\r\n function Get-PassedArgsNoRoot { $passedArgs }\r\n} -ArgumentList 'abc'\r\n\r\nGet-PassedArgsRoot\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\nReturn 'abc'\r\n\r\nActual behavior\r\n---------------\r\nReturn nothing\r\n\r\n**PSv5.1**\r\n```\r\nPS:3> New-Module -Name ReloadingTest -ScriptBlock {\r\n>> $passedArgs = $args\r\n>> class Root { $passedIn = $passedArgs }\r\n>> function Get-PassedArgsRoot { [Root]::new().passedIn }\r\n>> function Get-PassedArgsNoRoot { $passedArgs }\r\n>> } -ArgumentList 'abc'\r\n\r\nModuleType Version Name ExportedCommands\r\n---------- ------- ---- ----------------\r\nScript 0.0 ReloadingTest {Get-PassedArgsNoRoot, Get-PassedArgsRoot}\r\n\r\n\r\n[C:\\]\r\nPS:4> Get-PassedArgsRoot\r\n[C:\\]\r\nPS:5> Get-PassedArgsNoRoot\r\nabc\r\n[C:\\]\r\nPS:6> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 5.1.14393.206\r\nPSEdition Desktop\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nBuildVersion 10.0.14393.206\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\n**PSv6.0.0-alpha.13**\r\n```\r\nPS C:\\> New-Module -Name ReloadingTest -ScriptBlock {\r\n>> $passedArgs = $args\r\n>> class Root { $passedIn = $passedArgs }\r\n>> function Get-PassedArgsRoot { [Root]::new().passedIn }\r\n>> function Get-PassedArgsNoRoot { $passedArgs }\r\n>> } -ArgumentList 'abc'\r\n\r\nModuleType Version Name ExportedCommands\r\n---------- ------- ---- ----------------\r\nScript 0.0 ReloadingTest {Get-PassedArgsNoRoot, Get-PassedArgsRoot}\r\n\r\n\r\nPS C:\\>\r\nPS C:\\> Get-PassedArgsRoot\r\nPS C:\\> Get-PassedArgsNoRoot\r\nabc\r\nPS C:\\> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nBuildVersion 3.0.0.0\r\nWSManStackVersion 3.0\r\nPSEdition Core\r\nPSRemotingProtocolVersion 2.3\r\nCLRVersion\r\nSerializationVersion 1.1.0.1\r\nGitCommitId v6.0.0-alpha.13\r\nPSVersion 6.0.0-alpha\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\n```","author":{"url":"https://github.com/daxian-dbw","@type":"Person","name":"daxian-dbw"},"datePublished":"2016-12-05T18:56:47Z","url":"https://github.com/PowerShell/PowerShell/issues/2841"}
| 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:0d7df121-f213-6973-d8b8-acd3ff6b4f72 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 957E:35F933:100545:172041:6AFDCCFB |
| html-safe-nonce | e9b00bc1dab03af5e5dad850023993db5ca1e972bdd8928939ad24eeba966995 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTdFOjM1RjkzMzoxMDA1NDU6MTcyMDQxOjZBRkRDQ0ZCIiwidmlzaXRvcl9pZCI6IjcxODkxNDYwNTk3NzAwMjMxNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 647509bc81b1811934126cd618a1d90e736720534e043082f8432baaf4e66faf |
| hovercard-subject-tag | issue:193580630 |
| 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/2841/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5c27cc59ad835f8dea4bf196cbc2686d64c806827eb0f9834c6bd807ce24ab92/PowerShell/PowerShell/issues/2841 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5c27cc59ad835f8dea4bf196cbc2686d64c806827eb0f9834c6bd807ce24ab92/PowerShell/PowerShell/issues/2841 |
| og:image:alt | Steps to reproduce New-Module -Name ReloadingTest -ScriptBlock { $passedArgs = $args class Root { $passedIn = $passedArgs } function Get-PassedArgsRoot { [Root]::new().passedIn } function Get-Passe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daxian-dbw |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26886a40b582b821a7a76351e0a2f42b6d6160854b6e2520db24f31fd7be5da7 |
| 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 | 68ebaa631a1d248d69ebde4b9c5defd3a19aeb2f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width