Title: `using module test` doesn't load the powershell class defined in 'test' if 'test.psd1' has 'FunctionToExport' or 'CmdletToExport' specified · Issue #4112 · PowerShell/PowerShell · GitHub
Open Graph Title: `using module test` doesn't load the powershell class defined in 'test' if 'test.psd1' has 'FunctionToExport' or 'CmdletToExport' specified · Issue #4112 · PowerShell/PowerShell
X Title: `using module test` doesn't load the powershell class defined in 'test' if 'test.psd1' has 'FunctionToExport' or 'CmdletToExport' specified · Issue #4112 · PowerShell/PowerShell
Description: Summary When test.psd1 file has 'FunctionToExport' or 'CmdletToExport' specified, the module script analyzer will skip parsing the module scripts and thus no type definitions would be retrieved back. and PSModuleInfo.GetExportedTypeDefin...
Open Graph Description: Summary When test.psd1 file has 'FunctionToExport' or 'CmdletToExport' specified, the module script analyzer will skip parsing the module scripts and thus no type definitions would be retrieved bac...
X Description: Summary When test.psd1 file has 'FunctionToExport' or 'CmdletToExport' specified, the module script analyzer will skip parsing the module scripts and thus no type definitions would ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4112
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`using module test` doesn't load the powershell class defined in 'test' if 'test.psd1' has 'FunctionToExport' or 'CmdletToExport' specified","articleBody":"Summary\r\n----------\r\nWhen test.psd1 file has 'FunctionToExport' or 'CmdletToExport' specified, the module script analyzer will skip parsing the module scripts and thus no type definitions would be retrieved back. and [`PSModuleInfo.GetExportedTypeDefinitions`](https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs#L553) doesn't handle this scenario well.\r\n\r\nRepro\r\n------\r\nStructure of the module 'test'\r\n```\r\nPS:146> tree.com F:\\tmp\\test /F\r\nF:\\TMP\\TEST\r\n test.psd1\r\n test.psm1\r\n```\r\nContent of 'test.psd1'\r\n```\r\n@{\r\nModuleVersion = '1.0'\r\nGUID = 'e812e452-6a43-4fe7-9738-375c2fbdd577'\r\nNestedModules = @(\"test.psm1\")\r\nFunctionsToExport = @('Get-Name')\r\nCmdletsToExport = @()\r\nVariablesToExport = '*'\r\nAliasesToExport = @()\r\n}\r\n```\r\nContent of 'test.psm1'\r\n```\r\nclass Foo\r\n{\r\n [string] $Name = \"Foo\"\r\n}\r\n\r\nfunction Get-Name\r\n{\r\n return \"Name\"\r\n}\r\n```\r\nContent of `run.ps1`\r\n```\r\nusing module F:\\tmp\\test\r\n\r\nclass Bar{\r\n [Foo] $foo = [Foo]::new()\r\n\r\n [void] Print()\r\n {\r\n Write-Host ($this.foo.Name)\r\n }\r\n}\r\n```\r\nRun `run.ps1`\r\n```\r\n.\\run.ps1\r\n```\r\n\r\nExpected Behavior\r\n--------------------\r\nRunning `run.ps1` should be successful.\r\n\r\nActual Behavior\r\n-----------------\r\nIt failed\r\n```\r\nPS:14> .\\run.ps1\r\nAt F:\\tmp\\run.ps1:4 char:6\r\n+ [Foo] $foo = [Foo]::new()\r\n+ ~~~\r\nUnable to find type [Foo].\r\nAt F:\\tmp\\run.ps1:4 char:19\r\n+ [Foo] $foo = [Foo]::new()\r\n+ ~~~\r\nUnable to find type [Foo].\r\n + CategoryInfo : ParserError: (:) [], ParseException\r\n + FullyQualifiedErrorId : TypeNotFound\r\n```\r\n\r\nEnvironment\r\n--------------\r\n```\r\nPS:15> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 6.0.0-beta\r\nPSEdition Core\r\nGitCommitId v6.0.0-beta.2-48-g598cebf7b2f0b5bb0b0add97c6393ccfaaa792f5-dirty\r\nOS Microsoft Windows 10.0.15063\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```","author":{"url":"https://github.com/daxian-dbw","@type":"Person","name":"daxian-dbw"},"datePublished":"2017-06-26T23:42:12Z","url":"https://github.com/PowerShell/PowerShell/issues/4112"}
| 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:7afa1bec-243e-262c-40b9-9a5003008464 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9E4:340F3:D16D5:13006A:6AFDC0CE |
| html-safe-nonce | 2a3f855774df08b26d5cdc3f2386cc0a76851867ea2d042a53dca93796fd9bf1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUU0OjM0MEYzOkQxNkQ1OjEzMDA2QTo2QUZEQzBDRSIsInZpc2l0b3JfaWQiOiI4MDczOTI5MjQyODA0MzM4ODk0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 74c9b66efcb5a61cd3697940e5054f775eebbdd6f6cc260aa51b738056200318 |
| hovercard-subject-tag | issue:238699477 |
| 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/4112/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1b69046813ea30bb9a63e970e953ac12382aa87640253a8c188673477252192/PowerShell/PowerShell/issues/4112 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1b69046813ea30bb9a63e970e953ac12382aa87640253a8c188673477252192/PowerShell/PowerShell/issues/4112 |
| og:image:alt | Summary When test.psd1 file has 'FunctionToExport' or 'CmdletToExport' specified, the module script analyzer will skip parsing the module scripts and thus no type definitions would be retrieved bac... |
| 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 | 35c6bf57da1370dc64866160540c0ee9f825f291935b3bf6ec5492b00e35f3a6 |
| 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 | ab48c73a2978548773f5f24717ed9e58508befdb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width