PowerShell / PowerShell/PSScriptAnalyzer
[refactor] [style] Simplify all `string.Format(CultureInfo.CurrentCulture, format, args)` to `string.Format(format, args)`
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Synopsis
This issue is a minor but extensive style refactoring proposal to replace all invocations of string.Format(IProvider, string, ...) where the provider is explicitly specified to be the literal CultureInfo.CurrentCulture with string.Format(string, ...).
The expected benefit is simpler, more readable code.
No Change In Behavior
This change will not alter any behavior, since the the string.Format method uses the current culture by default anyway if no provider is passed. As stated in the first sentence under the heading "String.Format Method > Remarks > Formatting and culture",
Generally, objects in the argument list are converted to their string representations by using the conventions of the current culture, which is returned by the CultureInfo.CurrentCulture property. You can control this behavior by calling one of the overloads of Format that includes a provider parameter.
Feedback
First, is the content/risk/benefit of this proposed style refactoring accurately characterized herein?
Second, if this proposal is reasonable, would it be acceptable for someone (e.g. me, @travis-c-lagrone) to submit a single PR resolving this proposal? Or would it be preferable to approach it gradually over the course of multiple PRs?
Third, part of my motivation for raising this issue is to better understand the reason (if any) why string.Format is so commonly invoked throughout the code base with the literal argument CultureInfo.CurrentCulture. So that if there is a reason (e.g. facilitate culture parameterization), I can better address it as I perform some deep spot refactoring for other issues these days.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在代码库中搜索使用字面量 CultureInfo.CurrentCulture provider 的 string.Format 调用,然后检查每个出现位置及其周围的测试或用法。确认只修改指定的重载调用,并确保完整测试套件仍然全部通过;完成的标准是所有匹配的调用都已在不改变行为的情况下得到简化。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- tooling
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100