Skip to content

Fix TEMP debugging #1065

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

Merged
merged 6 commits into from
Oct 28, 2019
Merged

Conversation

TylerLeonhardt
Copy link
Member

This isn't quite ready yet. But I wanted to share what it took.

@TylerLeonhardt
Copy link
Member Author

TylerLeonhardt commented Oct 12, 2019

NOTE: This last commit requires a change in PSRL.

@PowerShell PowerShell deleted a comment Oct 12, 2019
@TylerLeonhardt
Copy link
Member Author

Marking as ready for review but it does need that PSRL change to go in.

@TylerLeonhardt TylerLeonhardt marked this pull request as ready for review October 14, 2019 15:26
@@ -291,6 +292,25 @@ public void StartLogging(string logFilePath, PsesLogLevel logLevel)
{
_logger.LogInformation($"Debug NamedPipe: {config.InOutPipeName}\nDebug OutPipe: {config.OutPipeName}");

IServiceProvider serviceProvider = null;
if (!useExistingSession)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for not using useTempSession with inverted logic? That would seem to line up with the conceptual feature better to me, and feels like it aligns with "breaking out" of the normal code when the useTempSession switch is set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's fine - useExistingSession was just "what was there before"

Copy link
Member Author

Choose a reason for hiding this comment

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

changed it to useTempSession hopefully that's a bit more clear.

@@ -34,9 +36,10 @@ public class PsesDebugServer : IDisposable
_loggerFactory = factory;
_inputStream = inputStream;
_outputStream = outputStream;
_serverStart = new TaskCompletionSource<bool>();
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
_serverStart = new TaskCompletionSource<bool>();
_serverStarted = new TaskCompletionSource<bool>();

Copy link
Member Author

@TylerLeonhardt TylerLeonhardt Oct 14, 2019

Choose a reason for hiding this comment

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

gonna change this to _serverRunning as it will be used to "wait until the server is not running"

Copy link
Member Author

Choose a reason for hiding this comment

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

changed it to that because when the "result is set" it's like saying set the result of the "running". Let me know if you feel stronger about _serverStopped


public async Task WaitForShutdown()
{
await _serverStart.Task;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is server start, why does it get set on shutdown? Should it be something like serverStopped instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I guess it should be called like _serverRunning or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed it to that because when the "result is set" it's like saying set the result of the "running". Let me know if you feel stronger about _serverStopped

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd personally expect _serverRunning to complete after initialization. I'm good with _serverStopped, _serverSession, _shutdownRequested anything like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to _serverStopped!


namespace Microsoft.PowerShell.EditorServices.Server
{
internal static class PsesServiceCollection
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this is a static extensions class, maybe call it something like PsesServiceCollectionExtensions instead (i.e. it doesn't actually implement an collection of services)

@TylerLeonhardt
Copy link
Member Author

build might fail for this because of needed changes in #1066

but I've addressed all your feedback @rjmholt

@PowerShell PowerShell deleted a comment Oct 15, 2019
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.

Some of these comments might be outdated, started the review yesterday. If they're no longer applicable just skip em. Mostly nits, otherwise LGTM!


public async Task WaitForShutdown()
{
await _serverStart.Task;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd personally expect _serverRunning to complete after initialization. I'm good with _serverStopped, _serverSession, _shutdownRequested anything like that.

IServiceProvider languageServiceProvider,
PsesDebugServer psesDebugServer,
bool useExistingSession
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: move close paren to previous line

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!

});
}

public static IServiceCollection AddPsesDebugServices (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public static IServiceCollection AddPsesDebugServices (
public static IServiceCollection AddPsesDebugServices(

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!

_languageServer.WaitForShutdown().Wait();
if (_languageServer != null)
{
_languageServer.WaitForShutdown().Wait();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If WaitForShutdown returns a Task we should use GetAwaiter().GetResult() instead of Wait or Result. The latter two wrap exceptions in a AggregateException with a generic message and messes with the stack trace a bit (or rather doesn't fix it).

I know it's existing code, just something we should probably clean up as we see it.

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!

@TylerLeonhardt
Copy link
Member Author

All feedback addressed and rebased! The can be merged in really at any time it just won't work until PSRL is released.

@TylerLeonhardt
Copy link
Member Author

This is not being backported.

@TylerLeonhardt TylerLeonhardt merged commit aab80d1 into PowerShell:master Oct 28, 2019
@TylerLeonhardt TylerLeonhardt deleted the add-debug-tests branch October 28, 2019 16:43
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