PowerShell / PowerShell/PSScriptAnalyzer
Formatting the PowerShell script removes necessary pipe operator `|`
未关闭
还没有人认领这个 Issue。
Area - Formatter
Issue - Bug
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 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