PowerShell / PowerShell/PowerShellEditorServices

Hook up PSES events to PSEventManager

Aperta
#613 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Language Server Issue-Enhancement
Lingua principale
C#
Stelle
767
Fork
266
Merge medio
3g 16h
PR unite (30g)
1

Descrizione

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

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 tracciando gli IMessageHandlers esistenti nel registro dei componenti e confrontando il comportamento proposto di Register-EditorEvent con Register-EngineEvent, PSEventSubscriber e PSEngineEvent. Definisci le costanti dei nomi degli eventi, la registrazione dei subscriber, l'inoltro agli handler, l'accodamento nel runspace e il comportamento dell'output di EventArgs; il lavoro è completo quando più handler PowerShell e di linguaggi compilati possono coesistere senza sostituire gli handler esistenti.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.