Closed simonsabin closed 1 year ago
I'm going to subsume this issue as the actual root problem: while the extension loads PSSA, the module's cmdlets aren't available in the extension terminal, and they should be. If they were, you wouldn't be trying to load PSSA manually.
Partly. Really I would like to own the version of PSSA that I load as with any dependency. At present, neither the cmdlets are loaded, nor the module is marked as loaded and thus one can't even tell if loaded. and I really don't want to be checking for loaded assemblies, thats awful.
Currently all our PS modules are failing the PSSA testing phase when run within VSCode, thus have to run outside of VSC.
For owning the version of PSSA, I would recommend that you use powershell.developer.bundledModulesPath
to override the bundled modules. For stability reasons, PSES is set to only load its dependent modules (PSSA, PSReadLine, etc.) from that path, but that path is configurable for advanced usage. Note that you'll need to run the extension in development mode for that setting to be utilized.
That looks like a load of faff and I can probably live with the version bump, can't live with it just not working because you don't get the cmdlets and can't load the module
Definitely on my shortlist to get the cmdlets and module loaded in the main runspace so that this is usable.
We realized this actually isn't possible due to our architecture, so script analyzer will need to be run in a non-extension terminal
This issue has been marked as answered and has not had any activity in a day. It has been automatically closed for housekeeping purposes.
Got to same I'm really disappointed in this. That means no pester testing using psscript analyzer. All our module development is now broken because of this. Why can't you import the module rather than just the assembly? at least that way it can be detected and handled using the normal mechanisms.
So the problem is that the way PSSA is written prevents us from sharing it. It relies on a global singleton of shared state, once we've imported it and PSES is using it to analyze files and provide formatting, it cannot be used by a user in the Extension Terminal without clashing and then crashing 😢
Can we disable that behaviour so I can use PSSA
Simon Sabin
Yes, I believe that if you disable script analysis via the setting powershell.scriptAnalysis.enable
and disable formatting (editor settings editor.formatOnType
, editor.formatOnPaste
and editor.formatOnSave
) then PSSA should never get initialized, which would be a viable workaround for you. I can imagine a reasonable ask for a powershell.codeFormatting.enable
setting, but we don't currently have it.
Can’t you load it into an Assembly Load Context, or work with the PSSA module in order that they work together.
Simon Sabin
Prerequisites
Steps to reproduce
trying to import PSScriptAnalyser when using the Integrated Terminal fails as the powershell extension has already loaded the PSScriptAnalyzer assemblies. However the PSScriptAnalyzer module isn't loaded
This means you can't then use PSScriptAnalyzer commands
Expected behavior
Actual behavior
Environment data
Version
ms-vscode.powershell-2022.10.0
Visuals
No response