PowerShell / PowerShell/PSScriptAnalyzer
Format document converting timestamp within single quotes
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
From @sk82jack on December 14, 2018 0:20
System Details
System Details Output
### VSCode version: 1.30.0 c6e592b2b5770e40a98cb9c2715a8ef89aec3d74 x64
### VSCode extensions:
CoenraadS.bracket-pair-colorizer@1.0.61
eamodio.gitlens@9.2.0
ms-azure-devops.azure-pipelines@1.145.1
ms-python.python@2018.12.0
ms-vscode.csharp@1.17.1
ms-vscode.PowerShell@1.10.1
ms-vsliveshare.vsliveshare@0.3.1013
### PSES version: 1.10.1.0
### PowerShell version:
Name Value
---- -----
PSVersion 5.1.17763.134
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.134
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
When running format document on a script it is converting an ISO 8601 timestamp within a string to a more human-readable string.
The issue has been reproduced by someone in the PowerShell slack and if you want to try and reproduce it yourself then feel free. Script here https://github.com/sk82jack/PSFPL/blob/master/Tests/Private/ConvertTo-FplObject.Tests.ps1#L48
I am trying to copy the timestamp string from line 67 into line 48
Expected Behaviour
I'd expect text in quotes to not be altered.
Actual Behaviour
Probably best described by a gif:

Once it converts it it then starts being weird and reporting errors that weren't reported before:

So, if I Ctrl+Z and then format again and then it doesn't convert it but it does remove the single quote from the end of line 48. I think that must be related to the previously reported errors but it still reports errors after removing the quote:

So, I Ctrl+Z again and try and format again but the integrated console usually crashes at this point.
Attached Logs
Copied from original issue: PowerShell/vscode-powershell#1657
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Tests/Private/ConvertTo-FplObject.Tests.ps1 中的复现开始,尤其关注第 48 行和第 67 行,并通过 format document 命令复现该行为。跟踪格式化程序如何处理用单引号括起来的 ISO 8601 时间戳,并验证带引号的文本保持不变,同时不会引入解析错误或导致控制台崩溃。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 32/100