Skip to content

Use correct casing for cmdlets affects keywords #5158

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
6 tasks done
DrDallas opened this issue Mar 19, 2025 · 4 comments
Closed
6 tasks done

Use correct casing for cmdlets affects keywords #5158

DrDallas opened this issue Mar 19, 2025 · 4 comments
Labels
Area-Script Analysis Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! Resolution-Answered Will close automatically.

Comments

@DrDallas
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed 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 the setting "Code Formatting : Use Correct Casing / Use correct casing for cmdlets" is enabled, keyword casing is changed.

For example, this code

Try {
	# Do something
	get-item c:\
} Catch {
	# Catch something here
}

gets changed to

try {
	# Do something
	Get-Item c:\
} catch {
	# Catch something here
}

The expected outcome is

Try {
	# Do something
	Get-Item c:\
} Catch {
	# Catch something here
}

This is expected because the setting is specific (in name) to cmdlets, and not keywords.

The suggested fix would be to include a setting for both cmdlets and keywords. An alternative solution would be to change the setting description to accurately describe that it changes the case for both cmdlets and keywords.

PowerShell Version

Name                           Value                                                                                                                            
----                           -----                                                                                                                            
PSVersion                      5.1.27808.1000                                                                                                                   
PSEdition                      Desktop                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                          
BuildVersion                   10.0.27808.1000                                                                                                                  
CLRVersion                     4.0.30319.42000                                                                                                                  
WSManStackVersion              3.0                                                                                                                              
PSRemotingProtocolVersion      2.3                                                                                                                              
SerializationVersion           1.1.0.1                                                                                                                          

Name             : Visual Studio Code Host
Version          : 2025.3.0
InstanceId       : c96a408b-e742-4ff3-ab2e-78232b7bc984
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

Version: 1.96.0-insider (system setup)
Commit: 3551cb01fa6f3a838e2d160df704cc3debfb9896
Date: 2024-10-30T05:04:18.074Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.27808

Extension Version

Command not working:

Identifier
ms-vscode.powershell
Version
2025.3.0
Last Updated
2025-03-19, 10:30:18

Steps to Reproduce

Described in Summary section

Visuals

No response

Logs

No response

@DrDallas DrDallas added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Mar 19, 2025
@JustinGrote
Copy link
Collaborator

JustinGrote commented Mar 19, 2025

Hi @DrDallas, thanks for your submission!

This formatting comes from PSScriptAnalyzer. There was just a new release, could you try the vscode preview release (which includes the new release) and let us know if it continues?

If so, use Invoke-ScriptAnalyzer on the same script and if it does still occur, this belongs in PSScriptAnalyzer repo to fix, there's nothing we can do about it here.

@JustinGrote JustinGrote added Area-Script Analysis Needs: Author Feedback Please give us the requested feedback! Pending: External This issue is not fixed here, it is fixed in a dependent repo such as PowerShell,PSScriptAnalyzer and removed Needs: Triage Maintainer attention needed! labels Mar 19, 2025
@andyleejordan
Copy link
Member

This formatting comes from PSScriptAnalyzer. There was just a new release, could you try the vscode preview release (which includes the new release) and let us know if it continues?

Per OP they're using the pre-release v2025.3.0, which means they have PSSA v1.24.0 and that means the UseCorrectCasing rule is configurable: https://github.com/PowerShell/PSScriptAnalyzer/blob/main/docs/Rules/UseCorrectCasing.md

@DrDallas you can do what you want with UseCorrectCasing.CheckKeyword etc. you'll just need to use a PSSA settings file as we don't have that granularity in the extension's settings.

@andyleejordan andyleejordan added Resolution-Answered Will close automatically. and removed Needs: Author Feedback Please give us the requested feedback! Pending: External This issue is not fixed here, it is fixed in a dependent repo such as PowerShell,PSScriptAnalyzer labels Mar 19, 2025
Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Mar 19, 2025
Copy link
Contributor

This issue has been labeled as needing fix verification and has not had any activity a week. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants