Skip to content

Support -CustomPipeName - #871

Merged
TylerLeonhardt merged 4 commits into
PowerShell:masterfrom
TylerLeonhardt:support-custom-pipename
Mar 10, 2019
Merged

TylerLeonhardt merged 4 commits into
PowerShell:masterfrom
TylerLeonhardt:support-custom-pipename

Conversation

@TylerLeonhardt

@TylerLeonhardt TylerLeonhardt commented Feb 27, 2019 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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

return;
}
}
else if (customPipeNameIsSet)

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.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed.

return;
}
}
else

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.

Might be a good opportunity to take this out?

@TylerLeonhardt TylerLeonhardt Mar 6, 2019 •

Copy link
Copy Markdown
Member Author

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.

}

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

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.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed.

@TylerLeonhardt
TylerLeonhardt force-pushed the support-custom-pipename branch from be5bf58 to fc7b4ad Compare March 6, 2019 22:01

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.

LGTM as long as my concern below isn't valid

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

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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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