PowerShell / PowerShell/PSScriptAnalyzer

Rule Idea: .NET Constructor Auto Document/Align

オープン
#1,587 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Area - Rules Issue - Enhancement Issue - New Rule Up-for-Grabs
主要言語
C#
スター
2.2k
フォーク
414
平均マージ
13時間 1分
マージ済み PR(30日)
2

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提案されている PowerShell AST と reflection のアプローチを確認します。これには、OverloadDefinitions のコンストラクター メタデータと、変数およびオーバーロードされたコンストラクターに関する制限が含まれます。サポートするケースと、例の before/after 出力に期待されるフォーマットを定義してから、それらのケースに対する集中的なカバレッジを追加します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
powershell
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。