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

Avoid UI dependency in CloudCache by passing along the solution folder #56829

Merged
merged 8 commits into from
Oct 1, 2021

Conversation

CyrusNajmabadi
Copy link
Member

This allows CloudCache to avoid having to go retrieve the same information from teh UI thread from IVsSolution.

disposable.Dispose();
}
});
}
Copy link
Member Author

Choose a reason for hiding this comment

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

andrew informed us that our ICloudCache proxy will only expose IDisposable. So our consumption code only needs to handle that and not IAsyncDisposable. This greatly simplifies a ton of code.

VisualStudioServices.VS2019_10.CacheService,
// replace with CacheService.RelativePathBaseActivationArgKey once available.
new ServiceActivationOptions { ActivationArguments = ImmutableDictionary<string, string>.Empty.Add("RelativePathBase", solutionFolder) },
cancellationToken).ConfigureAwait(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.

this is the crux of hte change, where we pass the solution folder along as an activation arg.

var cacheService = await serviceBroker.GetProxyAsync<ICacheService>(VisualStudioServices.VS2019_10.CacheService, cancellationToken: cancellationToken).ConfigureAwait(false);
var cacheService = await serviceBroker.GetProxyAsync<ICacheService>(
VisualStudioServices.VS2019_10.CacheService,
// replace with CacheService.RelativePathBaseActivationArgKey once available.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you reference the cache service package, do you? Everything you use I think you get from VS.RPC.Contracts. I don't know that we'll ever declare a constant for this there. At least, there's no great place for 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.

At least, there's no great place for it.

Can't it be in a type exported from teh same assembly that exports ICacheService? You could also just make it a constant inside the ICacheService interface (though i don't love that).

Copy link
Contributor

@AArnott AArnott Sep 29, 2021

Choose a reason for hiding this comment

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

The assembly that exports ICacheService is the VS.RPC.Contracts assembly that I mentioned above.
Interfaces can't declare constants, last I checked. We would need to declare the constant on some other class in that assembly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interfaces can declare constants. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. But in trying this out, C# 8 is required, and C# forbids constants on interfaces except when targeting .NET Core 3.1 or later. VS.RPC.Contracts targets netstandard2.0 as net472 is still of course an important target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you guys not on C#8? :) I didn't know about teh netstandard issue. That certainly seems weird as netstandard should support this. Bummer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we absolutely leverage C# 8 -- C# 9, in fact. I don't mind using syntax that requires C# 9. But ya, your compiler forbids constants on interfaces except when targeting a runtime that supports the default method implementations feature.

}

protected sealed override async ValueTask<ICacheService> CreateCacheServiceAsync(CancellationToken cancellationToken)
protected sealed override async ValueTask<ICacheService> CreateCacheServiceAsync(string solutionFolder, CancellationToken cancellationToken)
{
var serviceContainer = await _serviceProvider.GetServiceAsync<SVsBrokeredServiceContainer, IBrokeredServiceContainer>().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.

Where does the switch from WaitAndGetResult to JTF.Run go so that this line won't deadlock?

Copy link
Member

Choose a reason for hiding this comment

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

There's the original change in SuggestedAction.cs.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner September 29, 2021 01:53
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

I admit I don't follow the dispose bit, but am not worried about it. 😄

@CyrusNajmabadi CyrusNajmabadi changed the base branch from main to release/dev17.0 September 29, 2021 02:47
@CyrusNajmabadi
Copy link
Member Author

@jinujoseph for review. this addresses the deadlock we're getting with CloudCache. I'd like to bring this into 17.0 so we can reenable that A/B test.

@AArnott
Copy link
Contributor

AArnott commented Sep 29, 2021

The cloudcache side of this change will be inserted with this PR.

@CyrusNajmabadi CyrusNajmabadi changed the base branch from release/dev17.0 to main September 30, 2021 20:54
@CyrusNajmabadi CyrusNajmabadi merged commit 4ba784b into dotnet:main Oct 1, 2021
@ghost ghost added this to the Next milestone Oct 1, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the cloudCacheFolder branch October 1, 2021 05:11
@RikkiGibson RikkiGibson modified the milestones: Next, 17.1.P1 Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants