PowerShell / PowerShell/PSScriptAnalyzer

Lines unaffected from sytax errors get formatted wrong on PowerShell 5

Aperta
#1,813 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Formatter Issue-Bug Up for Grabs
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

  1. Open a PowerShell 5 window
  2. Type the following code with intentional syntax errors:
$code = @"
@(
  @{
    ""
  }
  ""
)
test /parameter
"@

Invoke-Formatter $code

Expected behavior

Slash should not be seperated from parameter since it isn't affected from the syntax error.

@(
    @{
        ""
    }
    ""
)
test /parameter

Actual behavior

Slash is treated as an operator and is seperated from parameter. This behavior is unique to PowerShell 5 and does not occur in v7.

@(
    @{
        ""
    }
    ""
)
test / parameter

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable

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

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.20.0

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il caso di PowerShell 5 con Invoke-Formatter e lo snippet fornito con errore di sintassi, quindi segui il percorso del formatter che gestisce le righe non interessate dopo un errore di parsing. Il lavoro è completato quando PowerShell 5 mantiene la barra associata al parametro, in modo da corrispondere all’output previsto, senza modificare il comportamento esistente di PowerShell 7.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.