PowerShell / PowerShell/vscode-powershell

Adding an attribute to a variable prevents its appearance in the Outline

Offen
#3,913 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-UI Issue-Bug
Vorherrschende Sprache
TypeScript
Sterne
1.9k
Forks
548
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

When adding an attribute to a variable (in this case System.Diagnostics.CodeAnalysis.SuppressMessageAttribute, but the outcome is the same for other attributes such as ValidateSetAttribute), the variable will no longer appear the the 'Outline' panel.

Take this script for example:

$MyVariable = 'foobar'

The variable MyVariable appears in the 'Outline' panel. Now, add an attribute to it. In this case, I added the System.Diagnostics.CodeAnalysis.SuppressMessageAttribute attribute to disable the PSUserDeclaredVarsMoreThanAssignments warning from not using the variable in the current script.

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments', '')]
$MyVariable = 'foobar'

The script works correctly, and the attribute correctly disables the warning, but the variable no longer appears in the 'Outline' panel.

PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
1.66.1
8dfae7a5cd50421d10cd99cb873990460525a898
x64
Extension Version
ms-vscode.powershell@2021.12.0
Steps to Reproduce
  1. Create a variable in the top-level scope. (It appears in the Outline.)
  2. Add an attribute to it. (It no longer appears in the Outline)
Visuals

No response

Logs

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem mit den beiden PowerShell-Beispielen und verfolge, wie die Erweiterung Outline-Symbole für Variablen der obersten Ebene erzeugt, wobei die nicht annotierten und die attributierten Formen verglichen werden. Fertig, wenn eine attributierte Variable im Outline-Bereich erscheint, ohne das Verhalten des Skripts zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, typescript, vscode
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.