I put [ArgumentCompleter([MyType])] on a [string] parameter. Code is trying to treat the attribute as the type. Types don't have parantheses. But otherwise, the syntax for an attribute reference is similar to how you reference a type. Though, in this case, an attribute type reference would be [ArgumentCompleterAttribute]. I tried it with both a class passed to the attribute and a script block. Same results both times.
On a related note, when I try to run my script outside Code in Windows Terminal, PS 7.3.4 ignores the same [ArgumentCompleter()] attribute references. It acts as those attributes aren't there at all.
PowerShell Version
PS C:\Users\willp> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name: PowerShell
Id: ms-vscode.powershell
Description: Develop PowerShell modules, commands and scripts in Visual Studio Code!
Version: 2023.5.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell
Prerequisites
Summary
I put
[ArgumentCompleter([MyType])]
on a[string]
parameter. Code is trying to treat the attribute as the type. Types don't have parantheses. But otherwise, the syntax for an attribute reference is similar to how you reference a type. Though, in this case, an attribute type reference would be[ArgumentCompleterAttribute]
. I tried it with both a class passed to the attribute and a script block. Same results both times.On a related note, when I try to run my script outside Code in Windows Terminal, PS 7.3.4 ignores the same
[ArgumentCompleter()]
attribute references. It acts as those attributes aren't there at all.PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
I wrote the argument completer class shown below.
I then applied that attribute to my method's parameter. (Simplified version of the method shown below.)
Visuals
This screenshot shows how such code is rendered. Notice how the
ArgumentCompleter
attribute is in blue. It should be in a brown.Logs
No response