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

Migrate to new output window API #38653

Closed
wants to merge 12 commits into from

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Sep 12, 2019

Use the new output window API

@dibarbet dibarbet added this to the 16.4 milestone Sep 12, 2019
@dibarbet dibarbet requested a review from a team September 12, 2019 00:02
@dibarbet
Copy link
Member Author

Close/open to re-trigger tests.

@dibarbet dibarbet closed this Sep 12, 2019
@dibarbet dibarbet reopened this Sep 12, 2019
@dibarbet dibarbet marked this pull request as ready for review September 13, 2019 22:21
@dibarbet dibarbet requested a review from a team as a code owner September 13, 2019 22:21
@dibarbet dibarbet changed the title [WIP] Migrate to new output window API Migrate to new output window API Sep 13, 2019
@dibarbet
Copy link
Member Author

@heejaechang @sharwell ready for review

@dibarbet
Copy link
Member Author

The integration tests are failing as the roslyn package is failing to load. There is a new dependency on the IBrokeredServiceContainer that is not available in 16.3P4. So until the integration testing machines are on 16.4P1, this cannot be merged.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

👍 once we figure out the test issues

@@ -91,6 +92,7 @@
<MicrosoftNuGetBuildTasksVersion>0.1.0</MicrosoftNuGetBuildTasksVersion>
<MicrosoftPortableTargetsVersion>0.1.2-dev</MicrosoftPortableTargetsVersion>
<MicrosoftServiceHubClientVersion>2.0.48</MicrosoftServiceHubClientVersion>
<MicrosoftServiceHubFrameworkVersion>2.0.84</MicrosoftServiceHubFrameworkVersion>
Copy link
Member

Choose a reason for hiding this comment

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

Should this be kept in sync with MicrosoftServiceHubClientVersion? (Not sure if they are "related" versions or not...)

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 don't think it's necessary, and there are binding redirects in VS for both anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

You should link these two. Hubclient and Framework are changing some in tandem and you may suffer regressions if they are out of sync for your tests at runtime.

src/VisualStudio/Core/Def/RoslynPackage.cs Show resolved Hide resolved
src/VisualStudio/Core/Def/RoslynPackage.cs Show resolved Hide resolved

_asyncListener = asyncListenerProvider.GetListener(FeatureAttribute.OutputWindowLogger);
_threadingContext = threadingContext;
_serviceBrokerClient = new ServiceBrokerClient(serviceBroker, _threadingContext.JoinableTaskFactory);
Copy link
Member

Choose a reason for hiding this comment

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

Is there any overhead of creating multiple Clients, or is there some benefit of sharing things?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, I'll defer to Andrew

@AArnott is there any issue with sharing a single service broker client to retrieve various distinct services? Is there any benefit to doing that?

Copy link
Contributor

Choose a reason for hiding this comment

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

A ServiceBrokerClient is totally fine with you requesting several services from it. It's optimized for that. What you shouldn't do is share your ServiceBrokerClient with a lot of users/classes if you can avoid it. The AvailabilityChanged event can get noisy if it's raising events to a lot of listeners for services that aren't related to an individual handler. So basically if you're setting up multiple handlers for that event to inform different classes that all consume from the same ServiceBrokerClient, consider creating a separate ServiceBrokerClient (and each with its own IServiceBroker passed to it) for each of these classes.

var asyncToken = asyncListener.BeginAsyncOperation(nameof(InitializeWorkspaceFailureOutputWindowAsync));
Task.Run(async () =>
{
using var outputChannelStore = await serviceBrokerClient.GetProxyAsync<IOutputChannelStore>(VisualStudioServices.VS2019_4.OutputChannelStore).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.

What is this using syntax? I've never seeing a using block that was missing a parentheses around the expression to be disposed.
Regardless, this looks buggy. It appears you're acquiring a rental and disposing it immediately, only to then try to use the proxy that you just released the rental for. You should make sure the using block includes all uses of the rented proxy before disposing the rental.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a new C# 8 feature, so it's possible I'm using it incorrectly - https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/using

But as far as I understand it, the lifetime of the variable defined in the implicit using will be the scope where it is declared, and once it goes out will be disposed of properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That's awesome. Thanks for teaching me more about C# 8. In that case what you're doing here looks fine. I'm going to go simplify all my code now. :)

@AArnott
Copy link
Contributor

AArnott commented Sep 26, 2019

I want to call out that the API for the output window service that you're switching to is in flux. You can see what we're switching to here: https://dev.azure.com/devdiv/DevDiv/_git/VS.RPC.Contracts/pullrequest/202619?_a=overview

So I'd recommend you not complete this PR till we complete our PR and you've compensated for the changes.

@dibarbet
Copy link
Member Author

So I'd recommend you not complete this PR till we complete our PR and you've compensated for the changes.

Sounds good. I'll hold off for now, thanks for letting me know (and the comments!)

@jinujoseph jinujoseph removed this from the 16.4 milestone Dec 11, 2019
@dibarbet
Copy link
Member Author

Closing, #40044 removed one case and #40142 will add the service broker dependencies. Will open new PR using new API once the above are completed.

@dibarbet dibarbet closed this Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants