2022-08-20

PowerShell Intellisense in VS Code for user written functions

I use VS Code for developing scripts for my company. I am having the devil of a time figuring out how to have Intellisense show the function parameters for the functions I've written. An example:

function ShowMessageBox()
{
[CmdletBinding()]
param (
    [Parameter(Position=0,mandatory=$true)]$ButtonType, 
    [Parameter(Position=1,mandatory=$true)]$MessageIcon, 
    [Parameter(Position=2,mandatory=$true)]$MessageTitle, 
    [Parameter(Position=3,mandatory=$true)]$MessageBody
)
...
}

when I write a call to ShowMessageBox, I assumed that VS Code would somehow parse the parameter block and allow me to use tab expansion to see the parameter names, however, they're not. I've also used "comment based help" (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.2&viewFallbackFrom=powershell-6), specifically the .PARAMETER keyword, but I've been unsuccessful.

I've also tried turning on ISE mode: https://docs.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/how-to-replicate-the-ise-experience-in-vscode?view=powershell-7.2

Can someone point me to the mechanism for enabling intellisense for functions in my scripts?



No comments:

Post a Comment