Skip to content

More RemoteHostClient refactoring#43928

Merged
tmat merged 10 commits intodotnet:masterfrom
tmat:KeepAliveSession2
May 3, 2020
Merged

More RemoteHostClient refactoring#43928
tmat merged 10 commits intodotnet:masterfrom
tmat:KeepAliveSession2

Conversation

@tmat
Copy link
Member

@tmat tmat commented May 3, 2020

No description provided.

/// Lock for the <see cref="_globalNotificationsTask"/> task chain. Each time we hear
/// about a global operation starting or stopping (i.e. a build) we will '.ContinueWith'
/// this task chain with a new notification to the OOP side. This way all the messages
/// are properly serialized and appera in the right order (i.e. we don't hear about a
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

Suggested change
/// are properly serialized and appera in the right order (i.e. we don't hear about a
/// are properly serialized and appear in the right order (i.e. we don't hear about a
``` #Resolved

/// stop prior to hearing about the relevant start).
/// </summary>
private readonly object _globalNotificationsGate = new object();
private Task<GlobalNotificationState> _globalNotificationsTask = Task.FromResult(GlobalNotificationState.NotStarted);
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

cute :) #Resolved

if (previousTask.Result != GlobalNotificationState.NotStarted)
{
return previousTask.Result;
}
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

should we assert we're not in the 'Finished' state? can we oc what hte Finished state actually is? #Resolved

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

n/m. i read this wrong. #Resolved


/// <summary>
/// Lock for the <see cref="_globalNotificationsTask"/> task chain. Each time we hear
/// about a global operation starting or stopping (i.e. a build) we will '.ContinueWith'
Copy link
Member Author

@tmat tmat May 3, 2020

Choose a reason for hiding this comment

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

This code moved from RemoteHostClient. #Resolved

{
NotStarted,
Started,
Finished
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

i don't see the Finished value ever used. did i miss it?
#Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, it used to be used. I deleted that code :) Will remove this value.


In reply to: 419027233 [](ancestors = 419027233)


await _endPoint.InvokeAsync(
nameof(IRemoteHostService.OnGlobalOperationStarted),
new object[] { "" },
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

previously we sent empty string, now we send nothing, is that ok? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there probably used to be some bug in JSON-RPC. I tested this works.


In reply to: 419027340 [](ancestors = 419027340)

continuation, _cancellationToken, TaskContinuationOptions.None, TaskScheduler.Default);
}

async Task<GlobalNotificationState> continuation(Task<GlobalNotificationState> previousTask)
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

Suggested change
async Task<GlobalNotificationState> continuation(Task<GlobalNotificationState> previousTask)
return;
async Task<GlobalNotificationState> continuation(Task<GlobalNotificationState> previousTask)
``` #Resolved

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

IDE style is to have explicit exit above the local functions that way the read knows tehre's no 'outer' code that executes beyond that point. (same for the above method plx). #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I just moved the method. But I can add it. It looks odd though, maybe it would be better if the local function was above .


In reply to: 419027397 [](ancestors = 419027397)

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi May 3, 2020

Choose a reason for hiding this comment

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

I just moved the method. But I can add it. It looks odd though, maybe it would be better if the local function was above .

In general, IDE style is:

  1. local functions at the end. This enables someone to immediately see the main-thread code of the function without having to go through the helpers first.
  2. an explicit exit prior to the local functions. This ensures that you can immediately see there's no additional code that runs. And the local functions don't intersperse hte actual method code.
  3. local functions are PascalCased at the IDE layer. We tend think of them as 'scoped sibling helper methods' versus 'a local variable of a function type'.
  4. Optionally: sometimes we put // local functions above hte local functions. This has helped clarify things in PRs where sometimes it looks like a sibling method, and it gets confusing (esp. with captures) when you can't immediatley tell that it's a local-function. However, this is rarer now now that most people are comfortable with them.

Copy link
Member Author

@tmat tmat May 3, 2020

Choose a reason for hiding this comment

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

Seems like it's better then to make it a method because all of the above is just adding extra stuff to make it clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

tbh, that's my general preference. but i get the desire to occasionally have a helper method that is just scoped narrowly. in practice though, if your class is well contained, just having these be helper methods is 100% fine (And how we survived for decades) :)

Copy link
Member Author

@tmat tmat May 3, 2020

Choose a reason for hiding this comment

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

Especially the need to add a comment means the style is bad, imo.

@tmat tmat marked this pull request as ready for review May 3, 2020 00:53
@tmat tmat requested a review from a team as a code owner May 3, 2020 00:53
@tmat tmat force-pushed the KeepAliveSession2 branch from 91d8c69 to 75cbcee Compare May 3, 2020 01:11
@tmat tmat merged commit 65722f0 into dotnet:master May 3, 2020
@ghost ghost added this to the Next milestone May 3, 2020
@tmat tmat deleted the KeepAliveSession2 branch May 3, 2020 05:15
@jinujoseph jinujoseph added Area-IDE Concept-OOP Related to out-of-proc labels May 3, 2020
@JoeRobich JoeRobich modified the milestones: Next, 16.7.P2 May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Concept-OOP Related to out-of-proc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants