-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Reduce extension footprint when not in repository context #1802
Reduce extension footprint when not in repository context #1802
Conversation
Use all `Lazy<>` imports for ImportingConstructor.
Since IPullRequestSessionManager is a MEF component we can import Lazy<IPullRequestSessionManager> directly rather than going through IGitHubServiceProvider.GetService<IPullRequestSessionManager>().
No need to log when not in a Visual Studio process.
We can be more precise and only initialize VSGitExt when in the RepositoryOpen UIContext rather than the GitSccProvider UIContext.
Only load the GitContextPackage when there is an open repository.
Loading `mark_github` via `GitHub.UI;component/SharedDictionary.xaml` is taking a noticeable amount of time and causing multiple assemblies to load. Changed to placeholder shape in the hope that we can replace this with an inline XAML GitHub logo.
Co-Authored-By: Jamie Cansdale <[email protected]>
@jcansdale Thank you :) Can you please add @jialongcheng as a reviewer as well? He has more context on UI contexts than I. |
@PooyaZv, I tried adding @jialongcheng as a reviewer, but for some reason wasn't able to. 😕 @jialongcheng, do you know if there are any UIContexts I could use to differentiate between the Visual Studio process and Blend? Also, are there UIContexts for different versions of Visual Studio or would I need to use |
Bring the GitHub mark back into the menu (and start page)
@jcansdale we do not have a public UI context for checking if we are in Blend. What is your use case? |
The challenge is actually preventing the extension from running inside Blend. It appears that VS services are disabled inside Blend, but packages and MEF components are still loaded. We need to be very careful not to break when all of our services return null. 😢 Is there any way to prevent an extension's packages and MEF components from being loaded inside Blend? That would be ideal. |
@jcansdale Unfortunately we do not have a way at this point to prevent an extension's packages and MEF components from being loaded inside Blend. |
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.
Yep, my mistake was having TE/StartPage open. This works great!
The problem
@PooyaZv (Writing from VS platform team) wrote:
We appear to be loading 22 assemblies, even when a project isn't using GitHub (see #1799 for a breakdown).
What this PR does
Only create text view margins when in the context of a Git repository
Change
InlineCommentMarginProvider
andPullRequestFileMarginProvider
to lazy load their MEF dependencies and only return a margin when in the context of a Git repository.Remove dependency on
LogManager
fromGitContextPackage
GitContextPackage
is our custom UI context and is loaded whenever we're in the context of a Git repository. This a low level package and doesn't really need logging (which requires a few assemblies).Change
GitContextPackage
andVSGitExt
to useUICONTEXT.RepositoryOpen
instead ofGitSccProvider
It appears there is a UIContext for when a Git repository is open (
UICONTEXT.RepositoryOpen
). Previously we were usingGitSccProvider
, which loads whenever the Git SCC provider is available (which is most of the time).Stop using
SharedDictionary.xaml
for GitHub logoThe GitHub logo used on
View > Other Windows > GitHub
andStartPage > GitHub
was causing a cascade of assembly loads when theStartPage
orGitHub
command was visible. I've replaced theSharedDictionary.xaml
reference with a plain XAML placeholder. This causes only the containing assembly to load.Questions
Our custom UIContext is now the same as
UICONTEXT.RepositoryOpen
, but with the added restriction that the host process is Visual Studio (not Blend). I don't know if there is a built in UIContext that would allow us to do the same thing? @PooyaZv do you know?To do
How to test
StartPage
visible and theGitHub
pane hiddenCtrl D + M
) and search forgithub
GitHub.VisualStudio.dll
to have loaded (it contains the GitHub icon)GitHub.InlineReviews.dll
,GitHub.Exports.dll
andGitHub.Exports.Reactive.dll
to have loaded (these contain our MEF margin providers and MEF interfaces)Fixes #1799