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

Commit 98ce396

Browse files
committed
Dedupe files, remove reflection code
1 parent dc1c6bb commit 98ce396

27 files changed

+106
-1986
lines changed

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@
112112
<Compile Include="Services\ITeamExplorerServices.cs" />
113113
<Compile Include="Services\ITeamExplorerServiceHolder.cs" />
114114
<Compile Include="Services\INotificationService.cs" />
115+
<Compile Include="Services\IVSServices.cs" />
115116
<Compile Include="Services\Logger.cs" />
116117
<Compile Include="Services\Services.cs" />
117118
<Compile Include="Services\StatusBarNotificationService.cs" />
118-
<Compile Include="Services\VSServices.cs" />
119119
<Compile Include="Models\IConnection.cs" />
120120
<Compile Include="Properties\AssemblyInfo.cs" />
121121
<Compile Include="..\common\SolutionInfo.cs">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using GitHub.Models;
3+
4+
namespace GitHub.Services
5+
{
6+
public interface IVSServices
7+
{
8+
string GetLocalClonePathFromGitProvider();
9+
void Clone(string cloneUrl, string clonePath, bool recurseSubmodules);
10+
string GetActiveRepoPath();
11+
LibGit2Sharp.IRepository GetActiveRepo();
12+
IEnumerable<ISimpleRepositoryModel> GetKnownRepositories();
13+
string SetDefaultProjectPath(string path);
14+
15+
void ActivityLogMessage(string message);
16+
void ActivityLogWarning(string message);
17+
void ActivityLogError(string message);
18+
}
19+
}

src/GitHub.TeamFoundation.14/GitHub.TeamFoundation.14.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6464
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
6565
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
66+
<Reference Include="microsoft.visualstudio.shell.interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
6667
<Reference Include="NullGuard, Version=1.4.1.0, Culture=neutral, PublicKeyToken=1958ac8092168428, processorArchitecture=MSIL">
6768
<HintPath>..\..\packages\NullGuard.Fody.1.4.1\lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\NullGuard.dll</HintPath>
6869
<Private>True</Private>
@@ -100,6 +101,7 @@
100101
</ItemGroup>
101102
<ItemGroup>
102103
<Compile Include="Constants.cs" />
104+
<Compile Include="Services\VSServices.cs" />
103105
<Compile Include="Settings.cs" />
104106
<Compile Include="Base\EnsureLoggedInSection.cs" />
105107
<Compile Include="Base\TeamExplorerInvitationBase.cs" />
@@ -118,7 +120,7 @@
118120
<Compile Include="Home\WikiNavigationItem.cs" />
119121
<Compile Include="Sync\EnsureLoggedInSectionSync.cs" />
120122
<Compile Include="Sync\GitHubPublishSection.cs" />
121-
<Compile Include="TeamExplorerServices.cs" />
123+
<Compile Include="Services\TeamExplorerServices.cs" />
122124
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
123125
<Link>Key.snk</Link>
124126
</None>
@@ -129,6 +131,10 @@
129131
<None Include="packages.config" />
130132
</ItemGroup>
131133
<ItemGroup>
134+
<ProjectReference Include="..\..\submodules\libgit2sharp\LibGit2Sharp\LibGit2Sharp.csproj">
135+
<Project>{ee6ed99f-cb12-4683-b055-d28fc7357a34}</Project>
136+
<Name>LibGit2Sharp</Name>
137+
</ProjectReference>
132138
<ProjectReference Include="..\..\submodules\octokit.net\Octokit\Octokit.csproj">
133139
<Project>{08dd4305-7787-4823-a53f-4d0f725a07f3}</Project>
134140
<Name>Octokit</Name>

src/GitHub.TeamFoundation.14/TeamExplorerServices.cs renamed to src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs

File renamed without changes.

src/GitHub.Exports/Services/VSServices.cs renamed to src/GitHub.TeamFoundation.14/Services/VSServices.cs

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@
1111
using Microsoft.VisualStudio.Shell.Interop;
1212
using Microsoft.Win32;
1313
using System.Diagnostics;
14+
using Microsoft.TeamFoundation.Git.Controls.Extensibility;
15+
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
1416

1517
namespace GitHub.Services
1618
{
17-
public interface IVSServices
18-
{
19-
string GetLocalClonePathFromGitProvider();
20-
void Clone(string cloneUrl, string clonePath, bool recurseSubmodules);
21-
string GetActiveRepoPath();
22-
LibGit2Sharp.IRepository GetActiveRepo();
23-
IEnumerable<ISimpleRepositoryModel> GetKnownRepositories();
24-
string SetDefaultProjectPath(string path);
25-
26-
void ActivityLogMessage(string message);
27-
void ActivityLogWarning(string message);
28-
void ActivityLogError(string message);
29-
}
30-
3119
[Export(typeof(IVSServices))]
3220
[PartCreationPolicy(CreationPolicy.Shared)]
3321
public class VSServices : IVSServices
@@ -61,37 +49,30 @@ public string GetLocalClonePathFromGitProvider()
6149

6250
public void Clone(string cloneUrl, string clonePath, bool recurseSubmodules)
6351
{
64-
var gitExt = serviceProvider.TryGetService("Microsoft.TeamFoundation.Git.Controls.Extensibility.IGitRepositoriesExt, Microsoft.TeamFoundation.Git.Controls");
65-
var cloneOptionsType = Type.GetType("Microsoft.TeamFoundation.Git.Controls.Extensibility.CloneOptions, Microsoft.TeamFoundation.Git.Controls");
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 });
52+
var gitExt = serviceProvider.GetService<IGitRepositoriesExt>();
53+
gitExt.Clone(cloneUrl, clonePath, recurseSubmodules ? CloneOptions.RecurseSubmodule : CloneOptions.None);
6854
}
6955

70-
object GetRepoFromVS()
56+
IGitRepositoryInfo GetRepoFromVS()
7157
{
72-
var gitExt = serviceProvider.TryGetService("Microsoft.VisualStudio.TeamFoundation.Git.Extensibility.IGitExt, Microsoft.TeamFoundation.Git.Provider");
73-
var prop = gitExt?.GetType().GetProperty("ActiveRepositories");
74-
var activeRepositories = prop?.GetValue(gitExt) as IEnumerable;
75-
var e = activeRepositories?.GetEnumerator();
76-
if (e?.MoveNext() ?? false)
77-
return e.Current;
78-
return null;
58+
var gitExt = serviceProvider.GetService<IGitExt>();
59+
return gitExt.ActiveRepositories.FirstOrDefault();
7960
}
8061

8162
public LibGit2Sharp.IRepository GetActiveRepo()
8263
{
8364
var repo = GetRepoFromVS();
84-
if (repo != null)
85-
return serviceProvider.GetService<IGitService>().GetRepo(repo.GetType().GetProperty("RepositoryPath").GetValue(repo) as string);
86-
return serviceProvider.GetSolution().GetRepoFromSolution();
65+
return repo != null
66+
? serviceProvider.GetService<IGitService>().GetRepo(repo.RepositoryPath)
67+
: serviceProvider.GetSolution().GetRepoFromSolution();
8768
}
8869

8970
public string GetActiveRepoPath()
9071
{
9172
string ret = null;
9273
var repo = GetRepoFromVS();
9374
if (repo != null)
94-
ret = repo.GetType().GetProperty("RepositoryPath")?.GetValue(repo) as string;
75+
ret = repo.RepositoryPath;
9576
if (ret == null)
9677
ret = serviceProvider.GetSolution().GetRepoFromSolution()?.Info?.Path;
9778
return ret ?? String.Empty;

src/GitHub.TeamFoundation.15/Base/EnsureLoggedInSection.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/GitHub.TeamFoundation.15/Base/TeamExplorerGitAwareItemBase.cs

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)