PowerShell / PowerShell/PSScriptAnalyzer

Rule Idea: .NET Constructor Auto Document/Align

Aberta
#1,587 1 comentário 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Area - Rules Issue - Enhancement Issue - New Rule Up-for-Grabs
Linguagem predominante
C#
Estrelas
2.2k
Forks
415
Merge médio
13h 1min
PRs com merge (30d)
2

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece revisando a abordagem proposta de PowerShell AST e reflection, incluindo os metadados dos construtores provenientes de OverloadDefinitions e as limitações relacionadas a variáveis e construtores sobrecarregados. Defina os casos compatíveis e a formatação esperada para o exemplo de saída antes/depois e, em seguida, adicione cobertura focada para esses casos.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
powershell
Domínio
tooling
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.