Auto Correct Aliases incorrectly expands DSC resources name thinking its an alias of a cmdlet
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- powershell
- Ambito
- tooling
Direzione di ricerca
Inizia individuando il percorso del formatter che gestisce l'impostazione powershell.codeFormatting.autoCorrectAliases, quindi riproduci il problema con la configurazione DSC Package fornita. Verifica come il formatter distingue gli alias dei cmdlet dai nomi delle risorse DSC e conferma che la formattazione preservi Package continuando a correggere gli alias applicabili.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 using the powershell formatter to format a DSC script, it incorrectly expands DSC resource e.g Package gets expanded to Get-Package which is incorrect in context of DSC.
PowerShell Version
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : ConsoleHost
Version : 7.4.3
InstanceId : 18115bb7-f7da-45d7-bb4b-e3714de77d09
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
1.91.0
ea1445cc7016315d0f5728f8e8b12a45dc0a7286
arm64
Extension Version
ms-vscode.powershell@2024.2.2
Steps to Reproduce
- Add below snippet to VSCode with
"powershell.codeFormatting.autoCorrectAliases": trueset. - Make sure VSCode detects the langugae as Poweshell or manually set it, then run formatter using
Alt+Shift+F
Code Snippet
Configuration PackageTest
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Package PackageExample
{
Ensure = "Present"
Path = "$Env:SystemDrive\TestFolder\TestProject.msi"
Name = "TestPackage"
ProductId = "ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E"
}
}
Expected behavior
Configuration PackageTest {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Package PackageExample
{
Ensure = 'Present'
Path = "$Env:SystemDrive\TestFolder\TestProject.msi"
Name = 'TestPackage'
ProductId = 'ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E'
}
}
Actual behavior
Configuration PackageTest {
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Get-Package PackageExample
{
Ensure = 'Present'
Path = "$Env:SystemDrive\TestFolder\TestProject.msi"
Name = 'TestPackage'
ProductId = 'ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E'
}
}
Visuals
No response
Logs
No response
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 415
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 commento ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Tutte le issue di PowerShell/PSScriptAnalyzer
Issue simili
-
Status: Waiting triage Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
nanoframework/Home#1857 ·
-
kind/bug kind/regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
unoplatform/uno.toolkit.ui#1646 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nightscout/nocturne#1379 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
elastic/esql-dotnet#47 ·
-
port: add go-steam fork Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100