Skip to content

Support unloaded enums and classes in Intellisense #2312

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

Closed
cdelcambre opened this issue Nov 18, 2019 · 5 comments
Closed

Support unloaded enums and classes in Intellisense #2312

cdelcambre opened this issue Nov 18, 2019 · 5 comments
Labels
Area-IntelliSense Bug: PowerShell Core Bugs when using PowerShell Core. Issue-Enhancement A feature request (enhancement).

Comments

@cdelcambre
Copy link

cdelcambre commented Nov 18, 2019

VSCode Version: 1.40.1
OS Version: Windows 10, 1903
Powershell Extension: 2019.11.0

Steps to Reproduce:

Create an Enum
Create a function which references that Enum as a parameter.
Call that function, there will be no autosense when populating the parameters and values for said function.

Simple Example

Enum AzureSqlEdition
{
Standard
Premium
Basic
}

function functAutoSenseBroke
{
param
(
[Parameter(Mandatory=$True)][AzureSqlEdition]$DbType,
[Parameter(Mandatory=$True)][string]$OtherParameter
)
Write-Host $DbType
Write-Host $OtherParameter
}

function functAutoSenseWorks
{
param ( [Parameter(Mandatory=$True)][string]$DbType )
Write-Host $DbType
}
#works but no autosense
functAutoSenseBroke -DbType ([AzureSqlEdition]::Standard) -OtherParameter "other"

#Simple Function, no Enum, autosense works, for comparison purposes
functAutoSenseWorks -DbType "test"
@ghost ghost added the Needs: Triage Maintainer attention needed! label Nov 18, 2019
@SydneyhSmith
Copy link
Collaborator

@cdelcambre thanks for opening this issue, and providing repro steps! I want to ensure that I understand what intellisense you are looking for/expecting, because I am having some trouble reproducing the issue
image
image
image

It would be great if you could attach a gif/screenshot or a description of what intellisense you are looking for--thanks!

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Nov 18, 2019
@cdelcambre
Copy link
Author

Thank you for looking into this @SydneyhSmith! Your screen shots are exactly what I am hoping for but I don't get what you get on the function functAutoSenseBroke. For both I get a long list of nonsense parameter name suggestions I could definitely live without. Typing the text of the parameter I am looking for narrows down the noise. Perhaps that's a symptom of my problem because I don't see that long list of noise suggestions in your screen shots. Maybe I have a config issue? This is a clean install done today of both VS code and PowerShell extension. All default settings.

image

image

Noise!
image

Extension Details
image

VS Code Details:
Version: 1.40.1 (user setup)
Commit: 8795a9889db74563ddd43eb0a897a2384129a619
Date: 2019-11-13T16:49:35.976Z
Electron: 6.1.2
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18362

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 19, 2019
@DarkLite1
Copy link

DarkLite1 commented Nov 19, 2019

I reported a similar issue in #2117 . For arguments sake I tried your example and have the same issue, there simply is no argument or parameter completion on the function Get-Stuff.

Enum AzureSqlEdition {
    Standard
    Premium
    Basic
}

Function Get-Stuff {
    [CmdLetBinding()]
    Param (
        [Parameter(Mandatory)]
        [AzureSqlEdition]$DbType,
        [Parameter(Mandatory)]
        [string]$OtherParameter
    )

    $PSBoundParameters
}

The completion is simply not done in the editor pane when typing partially -db to get the full parameter name -DbType. Even thought the suggestion on top says it is known:

image

But in the vscode-insiders console, after several tries, the completion is done correctly:
image

In the PowerShell ISE there is no problem when typing in the console pane:
image

But the same problem is happening when typing in the PowerShell ISE editor pane, no completion whatsoever:

image

This is happening on vscode-insiders with PowerShell Preview extension 2019.11.0:

Version: 1.41.0-insider (user setup)
Commit: 29b99f85e54aa5af6cd4edf918a67d4f70a10aea
Date: 2019-11-19T10:22:48.048Z
Electron: 6.1.4
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 6.2.9200

@SeeminglyScience
Copy link
Collaborator

Yeah completion acts differently when the source is also in the text it's trying to complete for. If you:

  1. Copy the whole script
  2. Paste it into a PSReadLine prompt without hitting enter or running any of the lines
  3. Put your cursor on the same spot and press tab

Then it'll probably act same. A very similar issue is PowerShell/PowerShell#10567. This is something that needs to be corrected in PowerShell itself (the engine provides the API that does all of vscode-powershell's completions)

@cdelcambre cdelcambre changed the title Autosense is broken when referencing a function which has an Enumerated Type as a parameter Intellisense is broken when referencing a function which has an Enumerated Type as a parameter Nov 19, 2019
@SydneyhSmith SydneyhSmith added Area-IntelliSense Issue-Bug A bug to squash. and removed Needs-Repro-Info Needs: Maintainer Attention Maintainer attention needed! labels Nov 19, 2019
@SydneyhSmith SydneyhSmith changed the title Intellisense is broken when referencing a function which has an Enumerated Type as a parameter Support unloaded enums and classes in Intellisense Nov 19, 2019
@SydneyhSmith SydneyhSmith added Resolution-External Will close automatically. Bug: PowerShell Core Bugs when using PowerShell Core. and removed Resolution-External Will close automatically. labels Nov 19, 2019
@rjmholt rjmholt added Issue-Enhancement A feature request (enhancement). and removed Issue-Bug A bug to squash. labels Mar 2, 2020
@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Mar 17, 2020

Closing as an external fix in PowerShell
PowerShell/PowerShell#12079

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

No branches or pull requests

5 participants