Skip to content

Conversation

@jborean93
Copy link
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

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

Great!

Copy link
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.

Copy link
Collaborator Author

@jborean93 jborean93 Sep 2, 2024

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
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
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.

@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
@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.
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

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