Closed LethiferousMoose closed 4 years ago
False alarm, I made some edits to the file and now everything works. Very strange.
It may be the performance issues in the current stable extension release. The red squigglies you mention above are parse errors in PowerShell where its class type checking is failing because the module exporting the classes you want can't be found. Once the module is imported that goes away, but the extension might not have made the updates to its representation of the file yet. That's something we've worked to improve in the coming release.
Thanks @rjmholt I was actually just coming back to ask a follow-up question, but that seems to answer it. It does happen consistently when first launching, then as soon as you make a file change it corrects itself, my guess if you are right and the modules aren't yet loaded on open.
It may actually be working as a side-effect of unintended module loading. See https://github.com/PowerShell/vscode-powershell/issues/715.
@rjmholt What is the expected outcome of #715? How will Intellisense work if it ends up not importing dependent modules?
Well that's something of an open question. On the one hand, intellisense in PowerShell is very much machine-state-driven, so I don't see any real way around it. On the other hand, importing modules as a side-effect of editing and getting completions is, I feel, not a great thing for an editor to do.
Similar to a lot of other scripting language extensions, we have a lot of users with different scenarios and expectations, but also unlike them, we're also very tied to the completion/discoverability experience that PowerShell includes by default in its own engine. These two things tend to clash, since PowerShell expects a certain usage pattern and some of our users have that pattern, but others have gotten used to how other programming language experiences (editors, linters, test integrations) and our machine-dependent experience has weaknesses there.
I'd like to see the extension become more about static completions and linting, since those things don't modify machine state, are reproduceable everywhere and scale well (so no thread management, async rabbit holes or deadlocks). But it's unlikely we'll be able to accomplish work like that any time soon (we've already invested heavily in a rearchitecture to move us off the old hand-rolled LSP infrastructure that the stable extension currently uses). Meaning you'll still need to load modules to get intellisense on them, and intellisense will still load modules.
But it all works (save for the odd edge case), has gotten faster (and is still improving -- next step is to make PSScriptAnalyzer substantially faster) and I think compares favourably with something like the ISE. I'd just like to see it look like the Python or the JS editing experience (which, once upon a time, I had set up in vim with full completions, help and linting, all pretty maintainably, on a small, unbeefy laptop, with no complaints).
System Details
System Details Output
Issue Description
I recently started using C# cmdlets and migrated a lot of classes from PowerShell into a shared location to be accessed between PowerShell and C# modules. After experimenting and getting assistance from the PowerShell team (see question) I found that in order to use custom classes from C# modules I am to include them in the
NestedModules
attribute on the manifest (psd1) file. This fixes all the issues I was having exposing the classes to the module, it does however not fix the VS Code plugin, as they are marked in red with errorUnable to find type
. Is this something the plugin can support?Expected Behaviour
Classes from C# module are detected by Intellisense.
Actual Behaviour
Classes from C# module are not detected by Intellisense.