PowerShell / PowerShell/PSScriptAnalyzer

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

Aperta
#1,274 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Engine Area - Formatter Consider - 2.0 Issue - Enhancement
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Cerca nella codebase le invocazioni di string.Format con il provider letterale CultureInfo.CurrentCulture, quindi esamina ogni occorrenza e i relativi test o l’utilizzo circostante. Conferma che vengano modificati solo gli overload specificati e che l’intera suite di test rimanga verde; il lavoro è completato quando tutte le invocazioni corrispondenti sono state semplificate senza modificare il comportamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
tooling
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.