From 4207f51c12e23f276a96f5ab1560aca0c3192258 Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Wed, 6 Feb 2019 11:39:52 +0000 Subject: [PATCH 1/2] Get the Git SccService before IGitActionsExt IGitActionsExt is proffered by SccProviderPackage, but isn't advertised. To ensure that getting IGitActionsExt doesn't return null, we first request the SccService which is advertised. This forces SccProviderPackage to load and proffer IGitActionsExt. --- .../Services/VSGitServices.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs b/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs index f27e693e34..d8cc4a4d68 100644 --- a/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs +++ b/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs @@ -86,6 +86,18 @@ public async Task Clone( NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home await WaitForCloneOnHomePageAsync(teamExplorer); #elif TEAMEXPLORER15 || TEAMEXPLORER16 + // IGitActionsExt is proffered by SccProviderPackage, but isn't advertised. + // To ensure that getting IGitActionsExt doesn't return null, we first request the + // SccService which is advertised. This forces SccProviderPackage to load + // and proffer IGitActionsExt. + var gitSccServiceGuid = new Guid("28C35EB2-67EA-4C5F-B49D-DACF73A66989"); + var gitSccServiceType = Type.GetTypeFromCLSID(gitSccServiceGuid); + var gitSccService = serviceProvider.GetService(gitSccServiceType); + if (gitSccService is null) + { + log.Warning("Couldn't find Git SccService with Guid {Guid}", gitSccServiceGuid); + } + // The progress parameter uses the ServiceProgressData type which is defined in // Microsoft.VisualStudio.Shell.Framework. Referencing this assembly directly // would cause type conflicts, so we're using reflection to call CloneAsync. From 5eec978b2798f11017d0e9ad51b04b791caa6ce6 Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Thu, 7 Feb 2019 15:09:43 +0000 Subject: [PATCH 2/2] Use IGitExt instead of internal SccService Force SccProviderPackage to load by getting IGitExt instead of the internal SccService. --- .../Services/VSGitServices.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs b/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs index d8cc4a4d68..023faaf0c1 100644 --- a/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs +++ b/src/GitHub.TeamFoundation.14/Services/VSGitServices.cs @@ -88,24 +88,20 @@ public async Task Clone( #elif TEAMEXPLORER15 || TEAMEXPLORER16 // IGitActionsExt is proffered by SccProviderPackage, but isn't advertised. // To ensure that getting IGitActionsExt doesn't return null, we first request the - // SccService which is advertised. This forces SccProviderPackage to load + // IGitExt service which is advertised. This forces SccProviderPackage to load // and proffer IGitActionsExt. - var gitSccServiceGuid = new Guid("28C35EB2-67EA-4C5F-B49D-DACF73A66989"); - var gitSccServiceType = Type.GetTypeFromCLSID(gitSccServiceGuid); - var gitSccService = serviceProvider.GetService(gitSccServiceType); - if (gitSccService is null) - { - log.Warning("Couldn't find Git SccService with Guid {Guid}", gitSccServiceGuid); - } + var gitExt = serviceProvider.GetService(typeof(IGitExt)); + Assumes.NotNull(gitExt); + var gitActionsExt = serviceProvider.GetService(); + Assumes.NotNull(gitActionsExt); // The progress parameter uses the ServiceProgressData type which is defined in // Microsoft.VisualStudio.Shell.Framework. Referencing this assembly directly // would cause type conflicts, so we're using reflection to call CloneAsync. - var gitExt = serviceProvider.GetService(); var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync)); Assumes.NotNull(cloneAsyncMethod); var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, cancellationToken, progress }; - var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters); + var cloneTask = (Task)cloneAsyncMethod.Invoke(gitActionsExt, cloneParameters); NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home await cloneTask;