-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Create new AsyncServiceProvider instead of using AsyncServiceProvider.GlobalProvider #74084
Conversation
….GlobalProvider AsyncServiceProvider.GlobalProvider is no longer an instance of AsyncServiceProvider, so the original code is failing.
@@ -455,7 +456,7 @@ public async Task<ImmutableArray<string>> GetF1KeywordsAsync(CancellationToken c | |||
ErrorHandler.ThrowOnFailure(vsView.GetBuffer(out var textLines)); | |||
ErrorHandler.ThrowOnFailure(textLines.GetLanguageServiceID(out var languageServiceGuid)); | |||
|
|||
var languageService = await ((AsyncServiceProvider)AsyncServiceProvider.GlobalProvider).QueryServiceAsync(languageServiceGuid).WithCancellation(cancellationToken); | |||
var languageService = await new AsyncServiceProvider((COMAsyncServiceProvider.IAsyncServiceProvider)AsyncServiceProvider.GlobalProvider).QueryServiceAsync(languageServiceGuid).WithCancellation(cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a fix for a downcast that wasn't documented to succeed, maybe your fix should avoid doing the same thing again. I believe the only supported way to get the COM IAsyncServiceProvider is by querying for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querying for it is easy enough. Do you know which service interface matches it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't a different service interface for it. So it would look like this:
AsyncServiceProvider.GlobalProvider.GetService<COMAsyncServiceProvider.IAsyncServiceProvider>()
You'll have to test it though. This is all based on my recollection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ I'll submit it as a separate follow-up PR since the current one already passed integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that will "work" as the managed version implements the native interface, but the right change is to query it as suggested by Andrew.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ Submitted #74100
AsyncServiceProvider.GlobalProvider
is no longer an instance ofAsyncServiceProvider
, so the original code is failing.