PowerShell / PowerShell/PSScriptAnalyzer

[refactor] [style] Simplify all `string.Format(CultureInfo.CurrentCulture, format, args)` to `string.Format(format, args)`

オープン
#1,274 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Area - Engine Area - Formatter Consider - 2.0 Issue - Enhancement
主要言語
C#
スター
2.2k
フォーク
414
平均マージ
13時間 1分
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

コードベースでリテラルの CultureInfo.CurrentCulture プロバイダーを指定した string.Format の呼び出しを検索し、その後、各箇所とその周辺のテストまたは使用箇所を確認します。指定されたオーバーロード呼び出しだけが変更され、完全なテストスイートが引き続きグリーンであることを確認します。完了とは、動作を変更せずに一致するすべての呼び出しが簡略化されていることを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
tooling
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。