Skip to content

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

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
5 of 6 tasks
mikebm94 opened this issue Apr 10, 2022 · 1 comment
Open
5 of 6 tasks
Labels
Area-UI Issue-Bug A bug to squash.

Comments

@mikebm94
Copy link

mikebm94 commented Apr 10, 2022

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

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

@mikebm94 mikebm94 added the Issue-Bug A bug to squash. label Apr 10, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Apr 10, 2022
@SydneyhSmith
Copy link
Collaborator

Thanks @mikebm94 for opening this issue and providing some details, looks like a bug

@SydneyhSmith SydneyhSmith added Area-UI and removed Needs: Triage Maintainer attention needed! labels Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UI Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

2 participants