PowerShell / PowerShell/PowerShellEditorServices

Hook up PSES events to PSEventManager

オープン
#613 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

Area-Language Server Issue-Enhancement
主要言語
C#
スター
767
フォーク
266
平均マージ
3日 16時間
マージ済み PR(30日)
1

説明

Right now the only way to register event/request handlers is to override them via IMessageHandlers from the component registry. This has a few issues

  1. As far as I can tell this only allows you to override handlers, not add to them. Doing this as part of an extension module would break existing functionality.

  2. These delegates are invoked from a thread that doesn't have a default runspace. This means if the delegate is a converted script block it will fail (and crash PSES)

I propose we add the following:

  1. Function or cmdlet Register-EditorEvent. This should work like Register-EngineEvent. It would take a SourceIdentifier as the event name and script block to register as a PSEventSubscriber. Ideally this would also include argument completion for event names.

  2. A class that holds constants with event names (see PSEngineEvent)

  3. Additional logic to existing handlers and other events to check for relevant event subscribers and if found generate the event.

  4. If the event/handler typically returns a value, a property would need to be added to the EventArgs to handle output (PowerShell eventing doesn't handle delegate output)

This would solve a few issues

  1. Extension modules could register additional handlers the same way in PowerShell and compiled languages

  2. Eventing should take care of all the runspace management and queuing of commands that would normally make this a huge pain. This would also allow the events to be ran in between sequence points of an in progress command.

  3. Allow multiple handlers for a single request/event

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

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

はじめの一歩

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

調査の方向性

まず、コンポーネント レジストリ内の既存の IMessageHandlers を追跡し、提案されている Register-EditorEvent の動作を Register-EngineEvent、PSEventSubscriber、PSEngineEvent と比較します。イベント名の定数、subscriber の登録、handler のディスパッチ、runspace へのキューイング、および EventArgs の出力動作を定義します。完了条件は、既存の handler を置き換えることなく、PowerShell とコンパイル言語の複数の handler が共存できることです。

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

評価

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

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

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