Skip to content

Add remote runspace check for PushRunspace#24239

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

Add remote runspace check for PushRunspace#24239
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 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 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 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
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Sep 10, 2024
jborean93 and others added 3 commits October 4, 2024 07:59
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.
Co-authored-by: Ilya <darpa@yandex.ru>

@SeeminglyScience SeeminglyScience left a comment

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!

@SeeminglyScience
SeeminglyScience merged commit 8aea111 into PowerShell:master Dec 4, 2024
@jborean93
jborean93 deleted the push-runspace branch December 4, 2024 17:24
@iSazonov iSazonov removed the Review - Needed The PR is being reviewed label Dec 4, 2024
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