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

Fix for Visual Studio 2019 Preview #2014

Merged
merged 7 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions GitHubVS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Wpf", "submodule
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstallAndStart", "test\Launcher\InstallAndStart.csproj", "{79F32BE1-2764-4DBA-97F6-21053DE44270}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.TeamFoundation.16", "src\GitHub.TeamFoundation.16\GitHub.TeamFoundation.16.csproj", "{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -542,6 +544,16 @@ Global
{79F32BE1-2764-4DBA-97F6-21053DE44270}.Release|Any CPU.Build.0 = Release|Any CPU
{79F32BE1-2764-4DBA-97F6-21053DE44270}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
{79F32BE1-2764-4DBA-97F6-21053DE44270}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugWithoutVsix|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.DebugWithoutVsix|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.Release|Any CPU.Build.0 = Release|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added lib/16.0/Microsoft.TeamFoundation.Client.dll
Binary file not shown.
Binary file added lib/16.0/Microsoft.TeamFoundation.Common.dll
Binary file not shown.
Binary file added lib/16.0/Microsoft.TeamFoundation.Controls.dll
Binary file not shown.
Binary file added lib/16.0/Microsoft.TeamFoundation.Git.Client.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 23 additions & 13 deletions src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading.Tasks;
using System.Windows.Input;
using GitHub.Api;
Expand All @@ -15,7 +14,6 @@
using GitHub.Primitives;
using GitHub.Services;
using GitHub.Settings;
using GitHub.UI;
using GitHub.VisualStudio.Base;
using GitHub.VisualStudio.Helpers;
using GitHub.VisualStudio.UI;
Expand All @@ -31,7 +29,7 @@ public class GitHubConnectSection : TeamExplorerSectionBase, IGitHubConnectSecti
{
static readonly ILogger log = LogManager.ForContext<GitHubConnectSection>();
readonly IPackageSettings packageSettings;
readonly IVSServices vsServices;
readonly ITeamExplorerServices teamExplorerServices;
readonly int sectionIndex;
readonly ILocalRepositories localRepositories;
readonly IUsageTracker usageTracker;
Expand Down Expand Up @@ -110,7 +108,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
ITeamExplorerServiceHolder holder,
IConnectionManager manager,
IPackageSettings packageSettings,
IVSServices vsServices,
ITeamExplorerServices teamExplorerServices,
ILocalRepositories localRepositories,
IUsageTracker usageTracker,
int index)
Expand All @@ -120,7 +118,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
Guard.ArgumentNotNull(holder, nameof(holder));
Guard.ArgumentNotNull(manager, nameof(manager));
Guard.ArgumentNotNull(packageSettings, nameof(packageSettings));
Guard.ArgumentNotNull(vsServices, nameof(vsServices));
Guard.ArgumentNotNull(teamExplorerServices, nameof(teamExplorerServices));
Guard.ArgumentNotNull(localRepositories, nameof(localRepositories));
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));

Expand All @@ -130,7 +128,7 @@ public GitHubConnectSection(IGitHubServiceProvider serviceProvider,
sectionIndex = index;

this.packageSettings = packageSettings;
this.vsServices = vsServices;
this.teamExplorerServices = teamExplorerServices;
this.localRepositories = localRepositories;
this.usageTracker = usageTracker;

Expand Down Expand Up @@ -462,15 +460,27 @@ public bool OpenRepository()
var old = Repositories.FirstOrDefault(x => x.Equals(Holder.ActiveRepo));
if (!Equals(SelectedRepository, old))
{
var opened = vsServices.TryOpenRepository(SelectedRepository.LocalPath);
if (!opened)
try
{
// TryOpenRepository might fail because dir no longer exists. Let user find solution themselves.
opened = ErrorHandler.Succeeded(ServiceProvider.GetSolution().OpenSolutionViaDlg(SelectedRepository.LocalPath, 1));
if (!opened)
var repositoryPath = SelectedRepository.LocalPath;
if (Directory.Exists(repositoryPath))
{
return false;
teamExplorerServices.OpenRepository(SelectedRepository.LocalPath);
}
else
{
// If directory no longer exists, let user find solution themselves
var opened = ErrorHandler.Succeeded(ServiceProvider.GetSolution().OpenSolutionViaDlg(SelectedRepository.LocalPath, 1));
if (!opened)
{
return false;
}
}
}
catch (Exception e)
{
log.Error(e, nameof(OpenRepository));
return false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public GitHubConnectSection0(IGitHubServiceProvider serviceProvider,
ITeamExplorerServiceHolder holder,
IConnectionManager manager,
IPackageSettings settings,
IVSServices vsServices,
ITeamExplorerServices teamExplorerServices,
ILocalRepositories localRepositories,
IUsageTracker usageTracker)
: base(serviceProvider, apiFactory, holder, manager, settings, vsServices, localRepositories, usageTracker, 0)
: base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 0)
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public GitHubConnectSection1(IGitHubServiceProvider serviceProvider,
ITeamExplorerServiceHolder holder,
IConnectionManager manager,
IPackageSettings settings,
IVSServices vsServices,
ITeamExplorerServices teamExplorerServices,
ILocalRepositories localRepositories,
IUsageTracker usageTracker)
: base(serviceProvider, apiFactory, holder, manager, settings, vsServices, localRepositories, usageTracker, 1)
: base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 1)
{
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/GitHub.TeamFoundation.14/Services/VSGitExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ public class VSGitExt : IVSGitExt
{
static readonly ILogger log = LogManager.ForContext<VSGitExt>();

readonly IAsyncServiceProvider asyncServiceProvider;
readonly IServiceProvider serviceProvider;
readonly ILocalRepositoryModelFactory repositoryFactory;
readonly object refreshLock = new object();

IGitExt gitService;
IReadOnlyList<ILocalRepositoryModel> activeRepositories;

public VSGitExt(IAsyncServiceProvider asyncServiceProvider)
: this(asyncServiceProvider, new VSUIContextFactory(), new LocalRepositoryModelFactory(), ThreadHelper.JoinableTaskContext)
public VSGitExt(IServiceProvider serviceProvider)
: this(serviceProvider, new VSUIContextFactory(), new LocalRepositoryModelFactory(), ThreadHelper.JoinableTaskContext)
{
}

public VSGitExt(IAsyncServiceProvider asyncServiceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
public VSGitExt(IServiceProvider serviceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
JoinableTaskContext joinableTaskContext)
{
JoinableTaskCollection = joinableTaskContext.CreateCollection();
JoinableTaskCollection.DisplayName = nameof(VSGitExt);
JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);

this.asyncServiceProvider = asyncServiceProvider;
this.serviceProvider = serviceProvider;
this.repositoryFactory = repositoryFactory;

// Start with empty array until we have a chance to initialize.
Expand Down Expand Up @@ -133,10 +133,9 @@ public void JoinTillEmpty()
async Task<T> GetServiceAsync<T>()
{
await JoinableTaskFactory.SwitchToMainThreadAsync();
return (T)await asyncServiceProvider.GetServiceAsync(typeof(T));
return (T)serviceProvider.GetService(typeof(T));
}


public event Action ActiveRepositoriesChanged;

JoinableTaskCollection JoinableTaskCollection { get; }
Expand Down
16 changes: 14 additions & 2 deletions src/GitHub.TeamFoundation.14/Services/VSGitServices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !TEAMEXPLORER14
#if TEAMEXPLORER15
// Microsoft.VisualStudio.Shell.Framework has an alias to avoid conflict with IAsyncServiceProvider
extern alias SF15;
using ServiceProgressData = SF15::Microsoft.VisualStudio.Shell.ServiceProgressData;
Expand Down Expand Up @@ -90,12 +90,24 @@ public async Task Clone(
await StartClonenOnConnectPageAsync(teamExplorer, cloneUrl, clonePath, recurseSubmodules);
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
await WaitForCloneOnHomePageAsync(teamExplorer);
#else
#elif TEAMEXPLORER15
var gitExt = serviceProvider.GetService<IGitActionsExt>();
var typedProgress = ((Progress<ServiceProgressData>)progress) ?? new Progress<ServiceProgressData>();
typedProgress.ProgressChanged += (s, e) => statusBar.Value.ShowMessage(e.ProgressText);
var cloneTask = gitExt.CloneAsync(cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), typedProgress);

NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
await cloneTask;
#elif TEAMEXPLORER16
// The ServiceProgressData type is in a Visual Studio 2019 assembly that we don't currently have access to.
// Using reflection to call the CloneAsync in order to avoid conflicts with the Visual Studio 2017 version.
// Progress won't be displayed on the status bar, but it appears prominently on the Team Explorer Home view.
var gitExt = serviceProvider.GetService<IGitActionsExt>();
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
Assumes.NotNull(cloneAsyncMethod);
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), null };
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);

NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
await cloneTask;
#endif
Expand Down
Loading