Title: Make PowerShell Classes Exportable Module Members · Issue #6293 · PowerShell/PowerShell · GitHub
Open Graph Title: Make PowerShell Classes Exportable Module Members · Issue #6293 · PowerShell/PowerShell
X Title: Make PowerShell Classes Exportable Module Members · Issue #6293 · PowerShell/PowerShell
Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Open Graph Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
X Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Opengraph URL: https://github.com/PowerShell/PowerShell
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make PowerShell Classes Exportable Module Members","articleBody":"Steps to reproduce\r\n------------------\r\n\r\nCurrently when classes are defined within a module it seems the best way to access them us with the following.\r\n\r\n```powershell\r\nusing module ModuleName\r\n[Foo]::new()\r\nGet-Module ModuleName\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nLike other module members (functions, cmdlets, variables, aliases, etc) it would be helpful to be able to declare classes and export them as module members. Module manifests could have a section for this.\r\n\r\n```powershell\r\nClassesToExport = @()\r\n```\r\n\r\nUsing them would feel more in line with how the rest of the language works. With the current implementation I find myself creating C# classes and importing the _.cs_ file with `Add-Type`.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\n> $PSVersionTable\r\nName Value\r\n---- -----\r\nPSVersion 6.0.1\r\nPSEdition Core\r\nGitCommitId v6.0.1\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```\r\n\r\n```powershell\r\n> $PSVersionTable\r\nName Value\r\n---- -----\r\nPSVersion 5.1.15063.909\r\nPSEdition Desktop\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nBuildVersion 10.0.15063.909\r\nCLRVersion 4.0.30319.42000\r\nWSManStackVersion 3.0\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\n```\r\n","author":{"url":"https://github.com/ephos","@type":"Person","name":"ephos"},"datePublished":"2018-03-02T15:35:12Z","url":"https://github.com/PowerShell/PowerShell/issues/6293"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:38b7f2e2-f2c5-567f-4301-583c625160ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D402:8B99E:BF1C4:11468F:6AFDC0D6 |
| html-safe-nonce | 2197b9f3f97ad62863aba0008559227fe7fa02c507a3d998d60fecea87023a9a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDAyOjhCOTlFOkJGMUM0OjExNDY4Rjo2QUZEQzBENiIsInZpc2l0b3JfaWQiOiIxNDAyOTY5MDk1MDExMTU2MTgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 21a8a313d1f080ff1558b8638d5544f5d655694af803c39875893d086659de60 |
| hovercard-subject-tag | repository:49609581 |
| 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/PowerShell/PowerShell/issues/6293 |
| twitter:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| og:image:alt | PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 35c6bf57da1370dc64866160540c0ee9f825f291935b3bf6ec5492b00e35f3a6 |
| turbo-cache-control | no-cache |
| 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