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

Commit 6117cc3

Browse files
committed
Remove dependencies on TeamFoundation
Remove all dependencies on TeamFoundation assemblies for all projects except the main one. Move any required TeamFoundation code to GitHub.VisualStudio Start aggregating all TeamFoundation-dependent code into one place
1 parent 3d273a7 commit 6117cc3

26 files changed

+78
-194
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@
5050
<DelaySign>false</DelaySign>
5151
</PropertyGroup>
5252
<ItemGroup>
53-
<Reference Include="Microsoft.TeamFoundation.Git.Controls, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
54-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Controls.dll</HintPath>
55-
<Private>False</Private>
56-
</Reference>
57-
<Reference Include="Microsoft.TeamFoundation.Git.Provider, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
58-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
59-
<Private>False</Private>
60-
</Reference>
6153
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6254
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6355
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />

src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
<Reference Include="System.ComponentModel.Composition" />
5151
<Reference Include="System.Core" />
5252
<Reference Include="System.Net.Http" />
53-
<Reference Include="Microsoft.TeamFoundation.Controls, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
54-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Controls.dll</HintPath>
55-
<Private>False</Private>
56-
</Reference>
5753
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=62aa029873c516b4, processorArchitecture=MSIL">
5854
<HintPath>..\..\packages\Rx-Core.2.2.5-custom\lib\net45\System.Reactive.Core.dll</HintPath>
5955
<Private>True</Private>

src/GitHub.Exports/Extensions/ServiceProviderExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System;
22
using System.ComponentModel.Design;
33
using System.Diagnostics;
4-
using GitHub.Primitives;
54
using GitHub.Services;
6-
using LibGit2Sharp;
7-
using Microsoft.TeamFoundation.Controls;
8-
using Microsoft.VisualStudio;
95
using Microsoft.VisualStudio.Shell;
10-
using Microsoft.VisualStudio.Shell.Interop;
116

127
namespace GitHub.Extensions
138
{
@@ -46,11 +41,6 @@ public static T GetService<T>(this IServiceProvider serviceProvider) where T : c
4641
return serviceProvider.TryGetService(typeof(T)) as T;
4742
}
4843

49-
public static ITeamExplorerSection GetSection(this IServiceProvider serviceProvider, Guid section)
50-
{
51-
return serviceProvider?.GetService<ITeamExplorerPage>()?.GetSection(section);
52-
}
53-
5444
static object GetServiceAndCache<CacheType>(IServiceProvider provider, Type type, ref CacheType cache)
5545
{
5646
object ret = null;

src/GitHub.Exports/Extensions/SimpleRepositoryModelExtensions.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22
using System.Linq;
33
using System.IO;
44
using GitHub.Models;
5-
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
65
using GitHub.Services;
76

87
namespace GitHub.Extensions
98
{
109
public static class SimpleRepositoryModelExtensions
1110
{
12-
/// <summary>
13-
/// Create a SimpleRepositoryModel from a VS git repo object
14-
/// </summary>
15-
public static ISimpleRepositoryModel ToModel(this IGitRepositoryInfo repo)
16-
{
17-
return repo == null ? null : new SimpleRepositoryModel(repo.RepositoryPath);
18-
}
19-
2011
public static bool HasCommits(this ISimpleRepositoryModel repository)
2112
{
2213
var repo = GitService.GitServiceHelper.GetRepo(repository.LocalPath);

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,6 @@
5151
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
5252
<EmbedInteropTypes>false</EmbedInteropTypes>
5353
</Reference>
54-
<Reference Include="Microsoft.TeamFoundation.Controls, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
55-
<HintPath>..\..\lib\\Microsoft.TeamFoundation.Controls.dll</HintPath>
56-
<Private>False</Private>
57-
</Reference>
58-
<Reference Include="Microsoft.TeamFoundation.Git.Controls, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
59-
<SpecificVersion>False</SpecificVersion>
60-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Controls.dll</HintPath>
61-
<Private>False</Private>
62-
</Reference>
63-
<Reference Include="Microsoft.TeamFoundation.Git.Provider, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
64-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
65-
<Private>False</Private>
66-
</Reference>
6754
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6855
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6956
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
@@ -127,7 +114,6 @@
127114
<Compile Include="Services\Logger.cs" />
128115
<Compile Include="Services\Services.cs" />
129116
<Compile Include="Services\StatusBarNotificationService.cs" />
130-
<Compile Include="Services\TeamExplorerServices.cs" />
131117
<Compile Include="Services\VSServices.cs" />
132118
<Compile Include="Models\IConnection.cs" />
133119
<Compile Include="Properties\AssemblyInfo.cs" />

src/GitHub.Exports/Services/GitService.cs

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.ComponentModel.Composition;
3-
using System.Linq;
1+
using System.ComponentModel.Composition;
42
using GitHub.Primitives;
53
using LibGit2Sharp;
6-
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
74

85
namespace GitHub.Services
96
{
@@ -62,71 +59,6 @@ public static UriString GetUriFromPath(string path)
6259
return GitServiceHelper.GetUri(path);
6360
}
6461

65-
/// <summary>
66-
/// Probes for a git repository and if one is found, returns a normalized GitHub uri
67-
/// <see cref="UriString"/> for the repository's remote named "origin" if one is found
68-
/// </summary>
69-
/// <remarks>
70-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
71-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
72-
/// either finds a repository, or reaches the root disk.
73-
/// </remarks>
74-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
75-
/// <returns>Returns a <see cref="UriString"/> representing the uri of the "origin" remote normalized to a GitHub repository url or null if none found.</returns>
76-
public UriString GetUri(IGitRepositoryInfo repoInfo)
77-
{
78-
return GetUri(GetRepo(repoInfo));
79-
}
80-
81-
/// <summary>
82-
/// Probes for a git repository and if one is found, returns a normalized GitHub uri
83-
/// <see cref="UriString"/> for the repository's remote named "origin" if one is found
84-
/// </summary>
85-
/// <remarks>
86-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
87-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
88-
/// either finds a repository, or reaches the root disk.
89-
/// </remarks>
90-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
91-
/// <returns>Returns a <see cref="UriString"/> representing the uri of the "origin" remote normalized to a GitHub repository url or null if none found.</returns>
92-
public static UriString GetUriFromVSGit(IGitRepositoryInfo repoInfo)
93-
{
94-
return GitServiceHelper.GetUri(repoInfo);
95-
}
96-
97-
/// <summary>
98-
/// Probes for a git repository and if one is found, returns a <see cref="IRepository"/> instance for the
99-
/// repository.
100-
/// </summary>
101-
/// <remarks>
102-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
103-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
104-
/// either finds a repository, or reaches the root disk.
105-
/// </remarks>
106-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
107-
/// <returns>An instance of <see cref="IRepository"/> or null</returns>
108-
109-
public IRepository GetRepo(IGitRepositoryInfo repoInfo)
110-
{
111-
return GetRepo(repoInfo?.RepositoryPath);
112-
}
113-
114-
/// <summary>
115-
/// Probes for a git repository and if one is found, returns a <see cref="IRepository"/> instance for the
116-
/// repository.
117-
/// </summary>
118-
/// <remarks>
119-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
120-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
121-
/// either finds a repository, or reaches the root disk.
122-
/// </remarks>
123-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
124-
/// <returns>An instance of <see cref="IRepository"/> or null</returns>
125-
public static IRepository GetRepoFromVSGit(IGitRepositoryInfo repoInfo)
126-
{
127-
return GitServiceHelper.GetRepo(repoInfo);
128-
}
129-
13062
/// <summary>
13163
/// Probes for a git repository and if one is found, returns a <see cref="IRepository"/> instance for the
13264
/// repository.

src/GitHub.Exports/Services/IGitService.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GitHub.Primitives;
22
using LibGit2Sharp;
3-
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
43

54
namespace GitHub.Services
65
{
@@ -26,33 +25,6 @@ public interface IGitService
2625
/// <returns>A <see cref="UriString"/> representing the origin or null if none found.</returns>
2726
UriString GetUri(string path);
2827

29-
/// <summary>
30-
/// Probes for a git repository and if one is found, returns a <see cref="UriString"/> for the repository's
31-
/// remote named "origin" if one is found
32-
/// </summary>
33-
/// <remarks>
34-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
35-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
36-
/// either finds a repository, or reaches the root disk.
37-
/// </remarks>
38-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
39-
/// <returns>A <see cref="UriString"/> representing the origin or null if none found.</returns>
40-
UriString GetUri(IGitRepositoryInfo repoInfo);
41-
42-
/// <summary>
43-
/// Probes for a git repository and if one is found, returns a <see cref="IRepository"/> instance for the
44-
/// repository.
45-
/// </summary>
46-
/// <remarks>
47-
/// The lookup checks to see if the path specified by the RepositoryPath property of the specified
48-
/// <see cref="repoInfo"/> is a repository. If it's not, it then walks up the parent directories until it
49-
/// either finds a repository, or reaches the root disk.
50-
/// </remarks>
51-
/// <param name="repoInfo">The repository information containing the path to start probing</param>
52-
/// <returns>An instance of <see cref="IRepository"/> or null</returns>
53-
54-
IRepository GetRepo(IGitRepositoryInfo repoInfo);
55-
5628
/// <summary>
5729
/// Probes for a git repository and if one is found, returns a <see cref="IRepository"/> instance for the
5830
/// repository.

src/GitHub.Exports/Services/IUIProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public interface IUIProvider : IServiceProvider
1515
Ret GetService<T, Ret>() where Ret : class;
1616

1717
object TryGetService(Type t);
18+
object TryGetService(string typename);
1819
T TryGetService<T>() where T : class;
1920

2021
void AddService(Type t, object instance);

src/GitHub.Exports/Services/VSServices.cs

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.ComponentModel.Composition;
45
using System.Globalization;
56
using System.Linq;
6-
using System.Windows.Input;
77
using GitHub.Extensions;
88
using GitHub.Models;
99
using GitHub.VisualStudio;
10-
using Microsoft.TeamFoundation.Controls;
11-
using Microsoft.TeamFoundation.Git.Controls.Extensibility;
1210
using Microsoft.VisualStudio;
1311
using Microsoft.VisualStudio.Shell.Interop;
14-
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
1512
using Microsoft.Win32;
1613
using System.Diagnostics;
1714

@@ -35,7 +32,7 @@ public interface IVSServices
3532
[PartCreationPolicy(CreationPolicy.Shared)]
3633
public class VSServices : IVSServices
3734
{
38-
readonly IServiceProvider serviceProvider;
35+
readonly IUIProvider serviceProvider;
3936

4037
[ImportingConstructor]
4138
public VSServices(IUIProvider serviceProvider)
@@ -64,25 +61,50 @@ public string GetLocalClonePathFromGitProvider()
6461

6562
public void Clone(string cloneUrl, string clonePath, bool recurseSubmodules)
6663
{
67-
var gitExt = serviceProvider.GetService<IGitRepositoriesExt>();
68-
gitExt.Clone(cloneUrl, clonePath, recurseSubmodules ? CloneOptions.RecurseSubmodule : CloneOptions.None);
64+
var gitExt = serviceProvider.TryGetService("Microsoft.TeamFoundation.Git.Controls.Extensibility.IGitRepositoriesExt");
65+
var cloneOptionsType = Type.GetType("Microsoft.TeamFoundation.Git.Controls.Extensibility.CloneOptions");
66+
var cloneMethod = gitExt.GetType().GetMethod("Clone", new Type[] { typeof(string), typeof(string), cloneOptionsType });
67+
cloneMethod.Invoke(gitExt, new object[] { cloneUrl, clonePath, recurseSubmodules ? 1 : 0 });
68+
//gitExt.Clone(cloneUrl, clonePath, recurseSubmodules ? CloneOptions.RecurseSubmodule : CloneOptions.None);
69+
}
70+
71+
object GetRepoFromVS()
72+
{
73+
var gitExt = serviceProvider.TryGetService("Microsoft.TeamFoundation.Git.Controls.Extensibility.IGitRepositoriesExt");
74+
var prop = gitExt?.GetType().GetProperty("ActiveRepositories");
75+
var activeRepositories = prop?.GetValue(gitExt) as IEnumerable;
76+
var e = activeRepositories?.GetEnumerator();
77+
if (e?.MoveNext() ?? false)
78+
return e.Current;
79+
return null;
6980
}
7081

7182
public LibGit2Sharp.IRepository GetActiveRepo()
7283
{
73-
var gitExt = serviceProvider.GetService<IGitExt>();
74-
return gitExt.ActiveRepositories.Any()
75-
? serviceProvider.GetService<IGitService>().GetRepo(gitExt.ActiveRepositories.First())
76-
: serviceProvider.GetSolution().GetRepoFromSolution();
84+
var repo = GetRepoFromVS();
85+
if (repo != null)
86+
return serviceProvider.GetService<IGitService>().GetRepo(repo.GetType().GetProperty("RepositoryPath").GetValue(repo) as string);
87+
return serviceProvider.GetSolution().GetRepoFromSolution();
88+
89+
//var gitExt = serviceProvider.GetService<IGitExt>();
90+
//return gitExt.ActiveRepositories.Any()
91+
// ? serviceProvider.GetService<IGitService>().GetRepo(gitExt.ActiveRepositories.First())
92+
// : serviceProvider.GetSolution().GetRepoFromSolution();
7793
}
7894

7995
public string GetActiveRepoPath()
8096
{
81-
var gitExt = serviceProvider.GetService<IGitExt>();
82-
if (gitExt.ActiveRepositories.Any())
83-
return gitExt.ActiveRepositories.First().RepositoryPath;
84-
var repo = serviceProvider.GetSolution().GetRepoFromSolution();
85-
return repo?.Info?.Path ?? string.Empty;
97+
string ret = null;
98+
var repo = GetRepoFromVS();
99+
if (repo != null)
100+
ret = repo.GetType().GetProperty("RepositoryPath")?.GetValue(repo) as string;
101+
if (ret == null)
102+
ret = serviceProvider.GetSolution().GetRepoFromSolution()?.Info?.Path ?? string.Empty;
103+
return ret;
104+
//var gitExt = serviceProvider.GetService<IGitExt>();
105+
//if (gitExt.ActiveRepositories.Any())
106+
// return gitExt.ActiveRepositories.First().RepositoryPath;
107+
//return serviceProvider.GetSolution().GetRepoFromSolution()?.Info?.Path ?? string.Empty;
86108
}
87109

88110
public IEnumerable<ISimpleRepositoryModel> GetKnownRepositories()

src/GitHub.Extensions/GitHub.Extensions.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@
5454
<SpecificVersion>False</SpecificVersion>
5555
<HintPath>..\..\packages\NullGuard.Fody.1.4.1\Lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\NullGuard.dll</HintPath>
5656
</Reference>
57-
<Reference Include="Microsoft.TeamFoundation.Git.Provider, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
58-
<HintPath>..\..\lib\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
59-
<Private>False</Private>
60-
</Reference>
6157
<Reference Include="System" />
6258
<Reference Include="System.ComponentModel.Composition" />
6359
<Reference Include="System.Core" />
@@ -71,7 +67,6 @@
7167
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
7268
<Link>Key.snk</Link>
7369
</None>
74-
<Compile Include="GitRepoExtensions.cs" />
7570
<Compile Include="LambdaComparer.cs" />
7671
<Compile Include="Properties\AssemblyInfo.cs" />
7772
<Compile Include="..\common\SolutionInfo.cs">

0 commit comments

Comments
 (0)