PowerShell / PowerShell/PSScriptAnalyzer

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

Abierto
#1,274 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Area - Engine Area - Formatter Consider - 2.0 Issue - Enhancement
Lenguaje dominante
C#
Estrellas
2.2k
Forks
414
Merge medio
13 h 1 min
PR fusionados (30 d)
2

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Busca en la base de código las invocaciones de string.Format con el proveedor literal CultureInfo.CurrentCulture y, después, inspecciona cada aparición y sus pruebas o uso circundantes. Confirma que solo se cambien las llamadas a las sobrecargas especificadas y que toda la suite de pruebas siga en verde; se considera terminado cuando todas las invocaciones coincidentes se hayan simplificado sin cambios de comportamiento.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
tooling
Tipo de issue
Refactorización
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.