PowerShell / PowerShell/PSScriptAnalyzer
Rule Idea: .NET Constructor Auto Document/Align
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 2.2k
- Forks
- 414
- Merge moyen
- 13 h 1 min
- PR mergées (30 j)
- 2
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner l’approche proposée basée sur PowerShell AST et la reflection, notamment les métadonnées des constructeurs provenant de OverloadDefinitions et les limitations liées aux variables et aux constructeurs surchargés. Définissez les cas pris en charge et le formatage attendu pour l’exemple de sortie avant/après, puis ajoutez une couverture ciblée pour ces cas.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- powershell
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100