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

Cleanup ServiceProviderExtensions, remove GetFreeThreadedServiceAsync as it's not longer needed #6215

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

nkolev92
Copy link
Member

@nkolev92 nkolev92 commented Jan 8, 2025

Bug

Fixes: NuGet/Home#14007

Description

Use the extension method https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.serviceextensions.getserviceasync?view=visualstudiosdk-2022 for service provider lookups. We no longer need our custom free threaded lookups.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests All existing tests should catch this.
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@nkolev92 nkolev92 marked this pull request as ready for review January 8, 2025 20:17
@nkolev92 nkolev92 requested a review from a team as a code owner January 8, 2025 20:17
}

return await AsyncServiceProvider.GlobalProvider.GetServiceAsync<TService, TInterface>();
return await AsyncServiceProvider.GlobalProvider.GetServiceAsync<TService, TInterface>(throwOnFailure: 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.

I switched from

await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // This is a fallback, primarily hit in tests.
            return Package.GetGlobalService(typeof(TService)) as TInterface;

to this.

Afaik, there's no gotchas in this switch.

cc @davkean

@nkolev92 nkolev92 requested a review from davkean January 8, 2025 20:18
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.

Cleanup ServiceProviderExtensions, remove GetFreeThreadedServiceAsync
1 participant