Repository navigation
Make PSEventManager.AddForwardedEvent public - #28199
Open
Jordan Borean (jborean93) wants to merge 2 commits into
Open
Jordan Borean (jborean93) wants to merge 2 commits into
Jordan Borean (jborean93) wants to merge 2 commits into
Conversation
Exposes `PSEventManager.AddForwardedEvent` publicly so third-party remoting transports can forward events from their sessions into the caller's event queue, the same way `New-PSSession`, `Invoke-Command` and `Start-Job` do. The public method adds a copy of the event and returns it, so the event passed in is not modified. The built-in cmdlet handlers now use the public method, so the event in the session/job runspace queue keeps the origin ID rather than one mutated by `AddForwardedEvent`. Custom transports using `RunspaceConnectionInfo` and `ClientSessionTransportManagerBase` receive forwarded events in `remoteRunspace.Events.ReceivedEvents`, but `AddForwardedEvent` was internal. Modules could only call `GenerateEvent`, which loses the original `ComputerName`, `RunspaceId` and `TimeGenerated`, or use reflection. `PSEventManager` still has internal abstract members, so it can't be subclassed outside the assembly and this isn't a breaking change.
Jordan Borean (jborean93)
requested review from
a team,
Travis Plunk (TravisEz13) and
Dongbo Wang (daxian-dbw)
as code owners
October 14, 2026 02:52
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The out-of-process test does not verify the captured originating runspace ID.
1 open finding
What changed in this PR
Exposes safe event forwarding for third-party remoting transports while preserving source-event metadata.
Changes:
- Adds public
PSEventManager.AddForwardedEvent. - Copies events before assigning local identifiers.
- Adds forwarding and metadata-preservation tests.
| File | Description |
|---|---|
EventManager.cs |
Adds the public copy-based forwarding API. |
remoterunspace.cs |
Retains internal in-place forwarding behavior. |
New-Event.Tests.ps1 |
Tests public and built-in forwarding paths. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

PR Summary
Exposes
PSEventManager.AddForwardedEventpublicly so third-party remoting transports can forward events from their sessions into the caller's event queue, the same wayNew-PSSession,Invoke-CommandandStart-Jobdo.The public method adds a copy of the event and returns it, so the event passed in is not modified. The built-in cmdlet handlers now use the public method, so the event in the session/job runspace queue keeps the origin ID rather than one mutated by
AddForwardedEvent.PR Context
Custom transports using
RunspaceConnectionInfoandClientSessionTransportManagerBasereceive forwarded events inremoteRunspace.Events.ReceivedEvents, butAddForwardedEventwas internal. Modules could only callGenerateEvent, which loses the originalComputerName,RunspaceIdandTimeGenerated, or use reflection.PSEventManagerstill has internal abstract members, so it can't be subclassed outside the assembly and this isn't a breaking change.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header