PowerShell / PowerShell/PSScriptAnalyzer
Rule request: `Get-Content x | ConvertFrom-Json` should suggest adding `-raw` for `Get-content`
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Summary of the new feature
When you call get-content file.json | convertfrom-json, funny things happen when file.json contains a comment at the top of the file.
Multiple places suggest that it's better to use get-content -raw for performance and predictability.
See:
- https://github.com/PowerShell/PowerShell/issues/12229
- https://stackoverflow.com/questions/71025659/set-property-value-on-object-loaded-from-json-containing-comments
Proposed technical implementation details (optional)
When get-content is piped to convertfrom-*, PSScriptAnalyzer should suggest adding -raw to get-content.
The same could apply to [xml] get-content file.xml.
What is the latest version of PSScriptAnalyzer at the point of writing
1.21
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件或测试。首先检查现有的 PSScriptAnalyzer 规则,了解将 Get-Content 通过管道传给 ConvertFrom-* 的情况,以及链接的 PowerShell issue;确定对 JSON 注释的预期处理方式和可能的 XML 情况。完成的标准是:分析器在适当情况下始终建议使用 -Raw,并且该行为有测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- devtools, tooling
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100