Repository navigation
Add public API for RemoteRunspace ShouldCloseOnPop - #28197
Open
Jordan Borean (jborean93) wants to merge 1 commit into
Open
Jordan Borean (jborean93) wants to merge 1 commit into
Jordan Borean (jborean93) wants to merge 1 commit into
Conversation
Adds a public method on `Runspace` that calls `RemoteRunspace.ShouldCloseOnPop = true`. This allows 3rd party modules to implement their own `Enter-PSSession ...` equivalent cmdlet where the runspace is closed when someone exits the session. Right now the only way to achieve this is to either create the PSSession manually and pass it to `Enter-PSSession -Session $s` or use reflection to set the internal property.
Jordan Borean (jborean93)
requested review from
a team,
Travis Plunk (TravisEz13) and
Dongbo Wang (daxian-dbw)
as code owners
October 14, 2026 02:21
|
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.
🟢 Approval recommended
The focused API addition is documented, validated, and covered by positive and negative integration tests.
0 open findings
What changed in this PR
Adds a supported API for marking remote runspaces to close after an interactive-session pop.
Changes:
- Adds
Runspace.SetShouldCloseOnPop(). - Adds localized error handling for local runspaces.
- Adds integration tests for close and retain behavior.
| File | Description |
|---|---|
Connection.cs |
Exposes the public API. |
remoterunspace.cs |
Clarifies internal flag documentation. |
RunspaceStrings.resx |
Adds the local-runspace error message. |
RunspaceShouldCloseOnPop.Tests.ps1 |
Tests validation and pop behavior. |
🧠 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
Adds a public method on
Runspacethat callsRemoteRunspace.ShouldCloseOnPop = true. This allows 3rd party modules to implement their ownEnter-PSSession ...equivalent cmdlet where the runspace is closed when someone exits the session. Right now the only way to achieve this is to either create the PSSession manually and pass it toEnter-PSSession -Session $sor use reflection to set the internal property.PR Context
See the summary, it enables 3rd party modules to implement their own equivalent to
Enter-PSSessionfor their own transports without relying on reflection and non-public APIs.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header