PowerShell / PowerShell/PSScriptAnalyzer
Formatting misses certain keywords (unary operators, 'until')
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 414
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
Descripción
I found that during formatting, some keywords aren't separated from leading braces (while), and some are seemingly ignored entirely (until). Also, unary operators (-not, -bnot, etc.) aren't separated with whitespace the same way as binary operators (-eq, -like, etc.).
Steps to reproduce
- Paste the following into a script
- Use Invoke-Formatter or the PowerShell VSCode extension to format the document
if(-not$false) {
do{
"Hello!"
}until(
$True
)
do{
"Oh, hi!"
}while(
-not$True
)
while(-not$True) {
"This won't show up."
}
}
Expected behavior
Roughly the following output. Some is dependent on brace style (OTBS in this case), but all rules for inserting whitespace around keywords and operators should be enabled.
if (-not $false) {
do {
'Hello!'
} until (
$True
)
do {
'Oh, hi!'
} while (
-not $True
)
while (-not $True) {
"This won't show up."
}
}
Actual behavior
if (-not$false) { # -not isn't separated by whitespace
do {
'Hello!'
}until( # no whitespace around Until
$True
)
do {
'Oh, hi!'
}while ( # only trailing whitespace for While
-not$True # no separation
)
while (-not$True) { # no separation for -not and -bnot
"This won't show up."
}
}
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.5737
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.5737
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.23.0
1.23.0 is the version included with the current (2025.0.0) VSCode PowerShell extension. I've also installed and tested 1.24.0 with the same results.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el reproducer proporcionado mediante Invoke-Formatter y compara el resultado con la salida esperada. Rastrea cómo el formatter gestiona los espacios de las palabras clave while y until, y después los operadores unarios como -not y -bnot. Se considera terminado cuando la salida formateada separa estas palabras clave y operadores como se muestra en los casos reportados.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, powershell
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 48/100