Title: PowerShell classes behaviour inconsistent · Issue #2449 · PowerShell/PowerShell · GitHub
Open Graph Title: PowerShell classes behaviour inconsistent · Issue #2449 · PowerShell/PowerShell
X Title: PowerShell classes behaviour inconsistent · Issue #2449 · PowerShell/PowerShell
Description: When you create a binary PowerShell module, just by compiling a simple, barebones C# class DLL and adding it to the module path (even without manifest), the class objects inside the DLL will be immediately available for that session afte...
Open Graph Description: When you create a binary PowerShell module, just by compiling a simple, barebones C# class DLL and adding it to the module path (even without manifest), the class objects inside the DLL will be imm...
X Description: When you create a binary PowerShell module, just by compiling a simple, barebones C# class DLL and adding it to the module path (even without manifest), the class objects inside the DLL will be imm...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/2449
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PowerShell classes behaviour inconsistent","articleBody":"\u003c!--\n\nIf it is a bug report:\n- make sure you are able to repro it on the latest released version. \nYou can install the latest version from https://github.com/PowerShell/PowerShell/releases\n- Search the existing issues.\n- Refer to the [FAQ](../docs/FAQ.md).\n- Refer to the [known issues](../docs/KNOWNISSUES.md).\n- Fill out the following repro template\n\nIf it's not a bug, please remove the template and elaborate the issue in your own words.\n-->\n\nWhen you create a binary PowerShell module, just by compiling a simple, barebones C# class DLL and adding it to the module path (even without manifest), the class objects inside the DLL will be immediately available for that session after the command 'import-module'.\n\nWhen you create a 'classic script based' PowerShell module (using .psm1/.psd1) the classes inside the module are only available to that module internally, but not to the PS session by default, unless you run the 'using module ...' command in the PowerShell session.\n\nThat by itself is already inconsistent. It gets more confusing when you create a new object using New-WebserviceProxy. The associated classes from the online web service are from then on also available in the current session, without any extra loading.\n\nSo, classes in 'foreign' modules are autoloaded and available, while 'PowerShell native' classes are not. This seems to be bug or at least inconsistent behaviour.\n\nIt would be great if the 'Export-ModuleMember' command was expanded to support classes as well.\n\n(I have a feeling this is an oversight. I spoke to someone at the PowerShell booth at Microsoft Ignite 2016 and the person was surprised classes inside text based .psm1 files are not available outside the module by default)\n\nSee also related comments on: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/16504684-package-powershell-classes-in-a-module\n## Steps to reproduce\n\nCreate new PowerShell module with classes inside. Classes not available by default when importing module.\n## Expected behavior\n\nClasses from binary PowerShell modules as well as classic, script based module should load in the same way.\n## Actual behavior\n\nYou need to explicitly call 'Using module ...' in the running PowerShell session in order to get access to the classes inside a script based PowerShell module.\n## Environment data\n\n\u003c!-- provide the output of $PSVersionTable -->\n\n``` powershell\n> $PSVersionTable\nName Value \n---- ----- \nPSVersion 5.1.14393.206 \nPSEdition Desktop \nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} \nBuildVersion 10.0.14393.206 \nCLRVersion 4.0.30319.42000 \nWSManStackVersion 3.0 \nPSRemotingProtocolVersion 2.3 \nSerializationVersion 1.1.0.1 \n```\n","author":{"url":"https://github.com/wimbor","@type":"Person","name":"wimbor"},"datePublished":"2016-10-10T19:03:48Z","url":"https://github.com/PowerShell/PowerShell/issues/2449"}
| 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:0295343e-17fe-43c3-48bb-6c62f0b3391b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC1C:266CD9:733750:A20641:6AFDC2A6 |
| html-safe-nonce | 5321040406643c2df267bec1abe2f43231451db947b131fcf9b74843bb11dc8f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzFDOjI2NkNEOTo3MzM3NTA6QTIwNjQxOjZBRkRDMkE2IiwidmlzaXRvcl9pZCI6IjI3NzczODIzNDY1NDA1NjUxNTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4b44bf709b84f58b111988ebdf2f940f41493e161f218b9045f1081b27bac251 |
| hovercard-subject-tag | issue:182090266 |
| 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/2449/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d731fbcf5ae57c093156b25438f940b09daca758caf3dc11cdc4d315deca3a41/PowerShell/PowerShell/issues/2449 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d731fbcf5ae57c093156b25438f940b09daca758caf3dc11cdc4d315deca3a41/PowerShell/PowerShell/issues/2449 |
| og:image:alt | When you create a binary PowerShell module, just by compiling a simple, barebones C# class DLL and adding it to the module path (even without manifest), the class objects inside the DLL will be imm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wimbor |
| 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