Title: How to write cross-PowerShell tools in .NET, particularly AST visitors? · Issue #10859 · PowerShell/PowerShell · GitHub
Open Graph Title: How to write cross-PowerShell tools in .NET, particularly AST visitors? · Issue #10859 · PowerShell/PowerShell
X Title: How to write cross-PowerShell tools in .NET, particularly AST visitors? · Issue #10859 · PowerShell/PowerShell
Description: Now that PowerShell has added more syntaxes and more features in other places, and also targets .NET Core 3.0, a challenge is apparent to maintainers of tools, in particular binary modules, that target multiple PowerShell versions. For e...
Open Graph Description: Now that PowerShell has added more syntaxes and more features in other places, and also targets .NET Core 3.0, a challenge is apparent to maintainers of tools, in particular binary modules, that ta...
X Description: Now that PowerShell has added more syntaxes and more features in other places, and also targets .NET Core 3.0, a challenge is apparent to maintainers of tools, in particular binary modules, that ta...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10859
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to write cross-PowerShell tools in .NET, particularly AST visitors?","articleBody":"Now that PowerShell has added more syntaxes and more features in other places, and also targets .NET Core 3.0, a challenge is apparent to maintainers of tools, in particular binary modules, that target multiple PowerShell versions.\r\n\r\nFor example, PSScriptAnalyzer currently targets:\r\n\r\n- PowerShell Standard with `netstandard2.0` for PowerShell 6+\r\n- PowerShell reference libraries with `net452` for Windows PowerShell 5.1- (it actually ships one set of DLLs per PowerShell version, making the module quite large)\r\n\r\nBut in PowerShell 7, new syntactic structures with their own ASTs like ternary expressions and pipeline chains have been added.\r\n\r\nPSScriptAnalyzer can't compile an `AstVisitor2` overriding `VisitTernaryExpression()` targeting PSStandard. So then perhaps it can target the PowerShell 7 SDK? Not without retargeting to .NET Core 3.0 from .NET Standard there.\r\n\r\nSo a list of some choices I see:\r\n\r\n- Continue with PSStandard and .NET Standard and be blind to new syntax. This is particularly unfriendly to PSScriptAnalyzer.\r\n- Add a .NET Core 3 compile target. For PSScriptAnalyzer this might be palatable, but in a case like PSES where the explicit move was made to PSStandard, this recomplicates the code and the build again, and if we support a .NET Core target, why not a .NET Framework one?\r\n- Build tooling to dynamically create the relevant methods, while still compiling for .NET Standard. This option prevents build difficulties, but makes writing the code much harder and more dangerous. More importantly, it's something that third party tool creators would have to grapple with (we would need to publish tools to make it possible).\r\n- Include new APIs in PowerShell Standard despite them not existing in old PowerShell versions. This would go against the idea of PSStandard, and is particularly bad since the old platforms won't throw nice exceptions (unlike in .NET Standard where it's the new platform that threw the exception)\r\n- Refactor relevant public parts of PowerShell (like the parser) to make it work with .NET Standard as a standalone (so for example, PSSA could embed it rather than relying on the current PowerShell version's parser). This would (1) be a fair amount of work, (2) mean removing .NET Core-specific code, and (3) change the mandate of these public components from \"works in PS 7\" to \"is backward compatible while still exposing new features\"\r\n\r\nNone of the choices above stands out to me, although there might be others.\r\n\r\nTL;DR: **What is PowerShell's story for exposing new important APIs to .NET libraries targeting multiple PowerShell versions?**\r\n\r\nThis question affects tools like PSScriptAnalyzer and PowerShell Editor Services, but also any other .NET library targeting multiple PowerShells, in particular binary modules and syntax-facing libraries.\r\n\r\n/cc @JamesWTruher @bergmeister @TylerLeonhardt @SeeminglyScience @daxian-dbw @joeyaiello @SteveL-MSFT ","author":{"url":"https://github.com/rjmholt","@type":"Person","name":"rjmholt"},"datePublished":"2019-10-21T22:08:24Z","url":"https://github.com/PowerShell/PowerShell/issues/10859"}
| 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:8e420e95-e06b-0e6c-865a-4b3cf567ceb4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82F4:497D3:552D6:739F0:6AFD487E |
| html-safe-nonce | 13ca31cac4f751d1b040723eebc7042f237e57160344edef8a5db1db0fbfb5f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkY0OjQ5N0QzOjU1MkQ2OjczOUYwOjZBRkQ0ODdFIiwidmlzaXRvcl9pZCI6IjM1NjE3MDMzMDI0Njg4MTQ5NzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e4b7ef8a1d48531b69eef125f0c9d118ea3fae64b5ef26be0b069120c797f40f |
| hovercard-subject-tag | issue:510321118 |
| 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/10859/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eed2521098ef075af386d4a0115bb861bed2ac9c2baffa86bd925fe041aa11d6/PowerShell/PowerShell/issues/10859 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eed2521098ef075af386d4a0115bb861bed2ac9c2baffa86bd925fe041aa11d6/PowerShell/PowerShell/issues/10859 |
| og:image:alt | Now that PowerShell has added more syntaxes and more features in other places, and also targets .NET Core 3.0, a challenge is apparent to maintainers of tools, in particular binary modules, that ta... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rjmholt |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| 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 | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width