PowerShell / PowerShell/PSScriptAnalyzer

Rule Idea: .NET Constructor Auto Document/Align

Abierto
#1,587 1 comentario 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Area - Rules Issue - Enhancement Issue - New Rule Up-for-Grabs
Lenguaje dominante
C#
Estrellas
2.2k
Forks
414
Merge medio
13 h 1 min
PR fusionados (30 d)
2

Descripción

Summary of the new feature

When instantiating dotnet objects with [Class]::new(), the syntax is generally obtuse for anyone coming along to read it. Reflection could be used to expand out the definition to the proper constructor from the OverloadDefinitions using the AST and comment the properties, since hashtable constructor syntax only works if the object has no constructors.

Proposed technical implementation details (optional)

Before:

[datetime]::new(2000, 6, 20)

After formatting:

[DateTime]::new(
    2000,   #int year
    6,      #int month
    20,     #int day
)

Major issue here would be variables, since Powershell is not statically typed it won't know what type the variable should be until runtime. This is only the problem in the case of overloaded constructors with the same number of arguments, maybe could still work if someone strongly typed the variable ahead of time that the AST could parse, e,g, [int]$Month?

What is the latest version of PSScriptAnalyzer at the point of writing
1.19.1.0

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

Comienza revisando el enfoque propuesto de PowerShell AST y reflection, incluidos los metadatos de los constructores de OverloadDefinitions y las limitaciones relacionadas con las variables y los constructores sobrecargados. Define los casos compatibles y el formato esperado para el ejemplo de salida antes/después y, a continuación, añade cobertura específica para esos casos.

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

Evaluación

Stack tecnológico
powershell
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.