Skip to content

Better intellisense for .NET? #1356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Rhywun opened this issue Jun 10, 2018 · 16 comments
Open

Better intellisense for .NET? #1356

Rhywun opened this issue Jun 10, 2018 · 16 comments
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).

Comments

@Rhywun
Copy link

Rhywun commented Jun 10, 2018

Issue Type: Feature Request

It would be very helpful to show popup documentation for .NET objects and members while coding in PowerShell, similar to what is already present for cmdlets. Is it possible with this extension or some other extension? The code completion for .NET objects works great but it would be nice to show the doc comments in the drowdowns and tooltips too.

Extension version: 1.7.0
VS Code version: Code 1.24.0 (6a6e02cef0f2122ee1469765b704faf5d0e0d859, 2018-06-06T17:30:30.113Z)
OS version: Darwin x64 16.7.0

@TylerLeonhardt
Copy link
Member

I like this idea - It would be nice to have something like this similar to what PSReadLine offers:

image

@TylerLeonhardt TylerLeonhardt added Issue-Enhancement A feature request (enhancement). Area-IntelliSense labels Jun 14, 2018
@rjmholt
Copy link
Contributor

rjmholt commented Sep 28, 2018

This should be possible by using PowerShell's API for getting PSMethod overload definitions.

e.g.

[string]::Combine.OverloadDefinitions

@SeeminglyScience
Copy link
Collaborator

SeeminglyScience commented Sep 28, 2018

This should be possible by using PowerShell's API for getting PSMethod overload definitions.
e.g.

[string]::Combine.OverloadDefinitions

We do already show that. The harder part is showing hints for the current parameter. Without type inference it's hard to tell what overload to show. Also the OverloadDefinitions property is just an array of strings, so we'd have to do some string manipulation to get specific parameters out of it (not saying that's impossible, just unfortunate)

In ESCS I ripped the type/member inference code from PowerShell, replacing internal API's with public ones. I'm testing it out there, if it goes well then porting it into PSES would make this a lot easier.

@rjmholt
Copy link
Contributor

rjmholt commented Sep 28, 2018

Also the OverloadDefinitions property is just an array of strings

Wow

@Castillu84
Copy link

"[System." is not recognized by Visual Studio Code Intellisence, nevertheless in PowerShell ISE is well recognized. In general, all the .net code in brackets [],is not detected in VSC.

intellisencenetexample

@SeeminglyScience
Copy link
Collaborator

@Castillu84 Can you double check that the language mode on the document is set to PowerShell?

Here's the results I get

image

@Castillu84
Copy link

Castillu84 commented Jan 16, 2019 via email

@Castillu84
Copy link

Hi again,

I found it behaivor is by design. The PowerShell module need to have the integrated console run.

screenshot1

Best Regards,

@SydneyhSmith
Copy link
Collaborator

Closing this issue as resolved

@rjmholt
Copy link
Contributor

rjmholt commented Mar 28, 2019

@SydneyhSmith going to reopen this one. Essentially, PSReadLine does parameter intellisense pretty well but it does something beyond PowerShell. This means it's possible, but we need to do extra work. It's not planned for us to work on, but is on the list of enhancements to make if anyone wants to give it a go.

@rjmholt rjmholt reopened this Mar 28, 2019
@NWarila
Copy link

NWarila commented Mar 14, 2022

Yeah as someone who has been using PowerShell ISE for years and only recently started to try and migrate VSCode there seems to be a number of growing pains that I feel could be avoided with some minor changes. Instead of requiring console to be open, would it make more sense to have a system console process that VSCode could open/manage to operate the intelligence. This would have the added benefit of per-session console caching. Not sure the feasibility of this, just a script kiddy but figured I would give my 2c.

@JustinGrote
Copy link
Collaborator

@NWarila the problem is due to the dynamic nature of Powershell, add-type, etc. doing it in a separate console can lead to inconsistent results unlike languages like C# where the types are all defined either up-front or in the documents, but aren't defined in the PS console dynamically at runtime or after module import. It was also done this way to be as close to the ISE as possible to help ease transition.

We can look at some of the more static types to be processed in a separate runspace but that will probably take some significant engineering.

@NWarila
Copy link

NWarila commented Mar 19, 2022

@JustinGrote, wouldn't it be possible to hook 2 consoles into the VSCode environment, one the user interacts with and one that is more or less "read only" per say that is used by the VSCode engine. Not arguing, just trying to better understand possibilities.

I understand it would be a performance hit to VSCode but I feel it would be quite minor considering the more consistent functionality gained. It would also help with issues where ctrl-c in the terminal causes the terminal to close abruptly, which seems semi-frequent occurence.

@JustinGrote
Copy link
Collaborator

@JustinGrote, wouldn't it be possible to hook 2 consoles into the VSCode environment, one the user interacts with and one that is more or less "read only" per say that is used by the VSCode engine. Not arguing, just trying to better understand possibilities.

I understand it would be a performance hit to VSCode but I feel it would be quite minor considering the more consistent functionality gained. It would also help with issues where ctrl-c in the terminal causes the terminal to close abruptly, which seems semi-frequent occurence.

Say you add-type in the first console and load an assembly. How is the second console supposed to know about it in order to intellisense it?

It's just too fragile, PowerShell is neither a strongly typed nor statically typed language, most of the constructs come from runtime, therefore the runtime has to supply it. Anything else would be a monumental amount of work unfortunately.

@shackcrack007
Copy link

is there any news about this issue?
see my full question here https://stackoverflow.com/questions/77895038/in-vscode-how-to-get-intellisense-working-for-powershell

@JustinGrote
Copy link
Collaborator

@shackcrack007 See #1356 (comment)

As a general rule we try not to put any magic intelligence into the extension/PSES if we can get away with it (e.g. string parsing of these overload definitions) because it is fragile and prone to breakage in obscure ways, and the proper solution would be to get a method exposed in PowerShell proper that would provide a typed version of this information, if we had that then implementing this becomes a lot easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

9 participants