Hook up PSES events to PSEventManager
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by tracing the existing IMessageHandlers in the component registry and comparing the proposed Register-EditorEvent behavior with Register-EngineEvent, PSEventSubscriber, and PSEngineEvent. Define the event-name constants, subscriber registration, handler dispatch, runspace queuing, and EventArgs output behavior; done means multiple PowerShell and compiled-language handlers can coexist without replacing existing handlers.
Written by the indexing model from the issue text.
Description
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
-
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.
-
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:
-
Function or cmdlet
Register-EditorEvent. This should work likeRegister-EngineEvent. It would take aSourceIdentifieras the event name and script block to register as aPSEventSubscriber. Ideally this would also include argument completion for event names. -
A class that holds constants with event names (see
PSEngineEvent) -
Additional logic to existing handlers and other events to check for relevant event subscribers and if found generate the event.
-
If the event/handler typically returns a value, a property would need to be added to the
EventArgsto handle output (PowerShell eventing doesn't handle delegate output)
This would solve a few issues
-
Extension modules could register additional handlers the same way in PowerShell and compiled languages
-
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.
-
Allow multiple handlers for a single request/event
- Dominant language
- C#
- Stars
- 767
- Forks
- 266
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Open
PowerShell/PowerShellEditorServices#2331 · 1 reaction · 2 assignees ·
-
Area-Language Server Issue-Enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PowerShell/PowerShellEditorServices#2315 · 1 comment ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 reaction · 2 assignees ·
-
Issue-Bug Needs: Triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PowerShell/PowerShellEditorServices#2293 · 1 comment ·
-
PowerShell/PowerShellEditorServices#2282 · 1 comment · 1 reaction · 2 assignees ·
All issues in PowerShell/PowerShellEditorServices
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nightscout/nocturne#1425 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cake-build/cake#5024 ·
-
Frontend status/draft TechnicalDebt
Difficulty 2/5 1-2 days Newbie friendliness 75/100
Altinn/altinn-auth#4143 ·