PowerShell / PowerShell/PSScriptAnalyzer

Rule Idea: .NET Constructor Auto Document/Align

Aperta
#1,587 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Rules Issue - Enhancement Issue - New Rule Up-for-Grabs
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

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

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

Inizia esaminando l’approccio proposto basato su PowerShell AST e reflection, inclusi i metadati dei costruttori provenienti da OverloadDefinitions e le limitazioni relative alle variabili e ai costruttori sovraccaricati. Definisci i casi supportati e la formattazione prevista per l’esempio di output prima/dopo, quindi aggiungi una copertura mirata per tali casi.

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

Valutazione

Stack tecnologico
powershell
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.