PowerShell / PowerShell/PowerShellEditorServices

Hook up PSES events to PSEventManager

Abierto
#613 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Area-Language Server Issue-Enhancement
Lenguaje dominante
C#
Estrellas
767
Forks
266
Merge medio
3 d 16 h
PR fusionados (30 d)
1

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza rastreando los IMessageHandlers existentes en el registro de componentes y comparando el comportamiento propuesto de Register-EditorEvent con Register-EngineEvent, PSEventSubscriber y PSEngineEvent. Define las constantes de nombres de eventos, el registro de suscriptores, el envío a los handlers, la puesta en cola en el runspace y el comportamiento de salida de EventArgs; se considera terminado cuando pueden coexistir varios handlers de PowerShell y de lenguajes compilados sin reemplazar los handlers existentes.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, powershell
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.