Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@grokys
Copy link
Contributor

@grokys grokys commented Feb 16, 2018

I used the VS2017 project system package as a template for the required attributes/procedure for this.

This required a bit of jiggling of the command infrastructure we have in the GitHub.InlineReviews package. This infrastructure was intended to be temporary, pending a command infrastructure that merges that in GitHub.VisualStudio. I'm looking into doing that right now, so don't dwell too much on that part of it.

Fixes #1489.

@grokys grokys requested review from jcansdale and shana February 16, 2018 10:07
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
PackageResources.Register(this, componentModel.DefaultExportProvider, menuService);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to go through GitHubServiceProvider for this. GitHubServiceProvider already loads up SComponentModel when it gets initialized and uses it for lookups, guaranteeing that only types that are ours get returned in MEF queries.

Going through GitHubServiceProvider also means that we can bypass the ExportProvider look up at any time by precaching instances in it ahead of time (which is handy for tests and also if we want to avoid a MEF query for some reason).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with GitHubServiceProvider is that it doesn't support async lookups, and given that we're in InitializeAsync I figured that we really should be doing these async. Or have I missed something?

@grokys
Copy link
Contributor Author

grokys commented Feb 22, 2018

@shana made the change we discussed.

Copy link
Collaborator

@jcansdale jcansdale left a comment

Choose a reason for hiding this comment

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

I think we should be using PackageAutoLoadFlags.BackgroundLoad.

[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(Guids.InlineReviewsPackageId)]
[ProvideAutoLoad(UIContextGuids80.SolutionExists)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will cause the package to auto-load on the Main thread. I think we should be using this:

    [ProvideAutoLoad(UIContextGuids80.SolutionExists, PackageAutoLoadFlags.BackgroundLoad)]

In future we might want to only auto-load when there is an active Git repository (see #1512)?

    [ProvideAutoLoad(Guids.UIContext_Git, PackageAutoLoadFlags.BackgroundLoad)]

@jcansdale
Copy link
Collaborator

Superseded by #1502.

@jcansdale jcansdale closed this Mar 14, 2018
@jcansdale jcansdale deleted the fixes/1489-inlinereviewspackage-async branch March 23, 2018 12:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants