Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support -CustomPipeName #871

Merged

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Feb 27, 2019

In PowerShell 6.2 RC we will introduce -CustomPipeName. The work is in this PR:
PowerShell/PowerShell#8889

This, along with PowerShell/vscode-powershell#1775 will add support for this parameter in the debug config that is passed to

Enter-PSHostProcess -CustomPipeName $foo

marking this as a Draft PR until RC is released.

@TylerLeonhardt
Copy link
Member Author

lets go ahead and switch these to a normal PR for review.

@@ -427,20 +426,27 @@ protected void Stop()

return;
}
}
else if (customPipeNameIsSet)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do all of the clauses above return? If so, is it possible to remove this else?

Copy link
Member Author

Choose a reason for hiding this comment

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

They don't all return. We have to keep this else in.

}
else if (customPipeNameIsSet)
{
if (runspaceVersion.Version.Major < 6 && runspaceVersion.Version.Minor < 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this works, it strikes me as less obvious than runspaceVersion.Version <= new Version(6, 1), which in the context of remoting is worth the minor allocation overhead to improve readability

Copy link
Contributor

Choose a reason for hiding this comment

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

(It's also something that could be cached statically if we really wanted to)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

$"Could not attach to process with CustomPipeName: '{attachParams.CustomPipeName}'");

return;
}
}
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good opportunity to take this out?

Copy link
Member Author

@TylerLeonhardt TylerLeonhardt Mar 6, 2019

Choose a reason for hiding this comment

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

Given they additional check to make sure processId is an int, refactoring to remove else just doesn't seem as readable as this.

@@ -454,6 +460,20 @@ protected void Stop()
return;
}

// Clear any existing breakpoints before proceeding
await ClearSessionBreakpointsAsync().ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await ClearSessionBreakpointsAsync().ConfigureAwait(false);
await ClearSessionBreakpointsAsync().ConfigureAwait(continueOnCapturedContext: false);

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

int runspaceId = attachParams.RunspaceId > 0 ? attachParams.RunspaceId : 1;
_waitingForAttach = true;
Task nonAwaitedTask =
_editorSession.PowerShellContext
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this on the line above

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

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 as long as my concern below isn't valid

.ContinueWith(OnExecutionCompletedAsync);
await _editorSession.PowerShellContext.ExecuteScriptStringAsync(
$"Enter-PSHostProcess -CustomPipeName {attachParams.CustomPipeName}",
errorMessages);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you still get intellisense while in the attached process? I would think that this would hold up the request queue, or does Enter-PSHostProcess return in the original runspace after attaching?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is so little time between Enter-PSHostProcess and the Debug-Runspace call bellow that it doesn't really matter. Debug-Runspace will for sure block any intellisense call until a breakpoint is hit. Then once a breakpoint is hit, it will work again but from the context of the breakpoint.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does that answer your question?

FWIW, I'm not changing that behavior in this PR. In the old version it still:

awaited Enter-PSHostProcess
not awaited Debug-Runspace

Copy link
Member Author

Choose a reason for hiding this comment

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

Talked about this offline. We are good.

@TylerLeonhardt TylerLeonhardt merged commit c9d4987 into PowerShell:master Mar 10, 2019
@TylerLeonhardt TylerLeonhardt deleted the support-custom-pipename branch March 10, 2019 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants