Skip to content

Add remote runspace check for PushRunspace - #24239

Merged
Patrick Meinecke (SeeminglyScience) merged 3 commits into
PowerShell:masterfrom
jborean93:push-runspace
Dec 4, 2024
Merged

Patrick Meinecke (SeeminglyScience) merged 3 commits into
PowerShell:masterfrom
jborean93:push-runspace

Conversation

@jborean93

Copy link
Copy Markdown
Collaborator

PR Summary

Add explicit exception when attempting to call PushRunspace on a runspace that is not remote. Instead of failing with a hard to understand NullReferenceException an ArgumentException is raised with information about what went wrong.

Fixes: #5735

PR Context

Someone in the PS Discord was trying to get this working and didn't know why it was failing. The issue #5735 was auto closed by the bot but I think this should still be in place.

While the RemoteRunspace check is in place on the default ConsoleHost I am not aware of any other implementations that work with a local Runspace so thought it best to just update the doc string to clearly indicate that the runspace should be a remote one.

PR Checklist

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is API comment I'd explicitly point it should be RemoteRunspace.

@jborean93 Jordan Borean (jborean93) Sep 2, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RemoteRunspace is not a public class so I can't really reference it in the API docs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be clearer, but I don't insist.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll leave it off unless others also prefer it in there. I'm unsure how the docs would actually be rendered if a non-public type was referenced here.

Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Outdated
@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 2, 2024
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Outdated
Add explicit exception when attempting to call PushRunspace on a
runspace that is not remote. Instead of failing with a hard to
understand NullReferenceException an ArgumentException is raised with
information about what went wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Jordan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConsoleHost.PushRunspace throws NullReferenceException when passed a local runspace

4 participants