PowerShell / PowerShell/PSScriptAnalyzer
Formatting the PowerShell script removes necessary pipe operator `|`
未關閉
還沒有人認領這個 Issue。
Area - Formatter
Issue - Bug
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
System Details
System Details Output
### VSCode version: 1.51.1 e5a624b788d92b8d34d1392e4c4d9789406efe8f x64
### VSCode extensions:
janisdd.vscode-edit-csv@0.6.0
ms-python.python@2021.2.633441544
ms-toolsai.jupyter@2021.2.576440691
ms-vscode.cpptools@1.1.3
ms-vscode.hexeditor@1.3.0
ms-vscode.powershell@2020.6.0
redhat.vscode-commons@0.0.6
redhat.vscode-xml@0.16.1
### PSES version: 2.2.0.0
### PowerShell version:
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
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
Issue Description
Create a PowerShell file, input following script, and hit Alt+Shift+F. The pipe operator in $a | ForEach-Object { $_ } is removed.
$a=@('a','b','c')
$b=@{
a=1
b=2
c=3
}
$b | Select-Object -Property ($a | ForEach-Object { $_ })
Related settings in settings.json:
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
Expected Behaviour
The format result should look like:
$a = @('a', 'b', 'c')
$b = @{
a = 1
b = 2
c = 3
}
$b | Select-Object -Property ($a | ForEach-Object { $_ })
Actual Behaviour
The format result is (note that the | is missing):
$a = @('a', 'b', 'c')
$b = @{
a = 1
b = 2
c = 3
}
$b | Select-Object -Property ($a ForEach-Object { $_ })
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
使用 issue 中所示的 PowerShell 指令碼和格式設定重現 formatter 問題,然後追蹤處理巢狀管線運算式的 PowerShell 格式化入口點。完成的標準是格式化輸出中保留內部的 |,並且有一個回歸測試涵蓋此範例;issue 未指出原始檔案或現有測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100