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

Commit 9175b2f

Browse files
authored
Merge pull request #2051 from github/fixes/stop-using-aliases
Use alias classes instead of alias references
2 parents 30fd494 + 1629cce commit 9175b2f

File tree

8 files changed

+25
-38
lines changed

8 files changed

+25
-38
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
105105
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
106106
<Private>True</Private>
107-
<Aliases>global</Aliases>
108107
</Reference>
109108
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
110109
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>

src/GitHub.TeamFoundation.14/Services/VSGitExt.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515

1616
namespace GitHub.VisualStudio.Base
1717
{
18+
// This is a workaround to avoid using reference aliases, which don't currently work with <PackageReference>.
19+
#if TEAMEXPLORER14
20+
public class VSGitExt14 : VSGitExt
21+
{
22+
public VSGitExt14(IServiceProvider serviceProvider, IGitService gitService) : base(serviceProvider, gitService) { }
23+
}
24+
#elif TEAMEXPLORER15
25+
public class VSGitExt15 : VSGitExt
26+
{
27+
public VSGitExt15(IServiceProvider serviceProvider, IGitService gitService) : base(serviceProvider, gitService) { }
28+
}
29+
#elif TEAMEXPLORER16
30+
public class VSGitExt16 : VSGitExt
31+
{
32+
public VSGitExt16(IServiceProvider serviceProvider, IGitService gitService) : base(serviceProvider, gitService) { }
33+
}
34+
#endif
35+
1836
/// <summary>
1937
/// This service acts as an always available version of <see cref="IGitExt"/>.
2038
/// </summary>

src/GitHub.TeamFoundation.14/Services/VSGitServices.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
#if TEAMEXPLORER15
2-
// Microsoft.VisualStudio.Shell.Framework has an alias to avoid conflict with IAsyncServiceProvider
3-
extern alias SF15;
4-
using ServiceProgressData = SF15::Microsoft.VisualStudio.Shell.ServiceProgressData;
5-
#endif
6-
7-
using System;
8-
using System.Threading;
1+
using System;
92
using System.Collections.Generic;
103
using System.Diagnostics.CodeAnalysis;
114
using System.ComponentModel.Composition;
@@ -90,22 +83,14 @@ public async Task Clone(
9083
await StartClonenOnConnectPageAsync(teamExplorer, cloneUrl, clonePath, recurseSubmodules);
9184
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
9285
await WaitForCloneOnHomePageAsync(teamExplorer);
93-
#elif TEAMEXPLORER15
94-
var gitExt = serviceProvider.GetService<IGitActionsExt>();
95-
var typedProgress = ((Progress<ServiceProgressData>)progress) ?? new Progress<ServiceProgressData>();
96-
typedProgress.ProgressChanged += (s, e) => statusBar.Value.ShowMessage(e.ProgressText);
97-
var cloneTask = gitExt.CloneAsync(cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), typedProgress);
98-
99-
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
100-
await cloneTask;
101-
#elif TEAMEXPLORER16
86+
#elif TEAMEXPLORER15 || TEAMEXPLORER16
10287
// The ServiceProgressData type is in a Visual Studio 2019 assembly that we don't currently have access to.
10388
// Using reflection to call the CloneAsync in order to avoid conflicts with the Visual Studio 2017 version.
10489
// Progress won't be displayed on the status bar, but it appears prominently on the Team Explorer Home view.
10590
var gitExt = serviceProvider.GetService<IGitActionsExt>();
10691
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
10792
Assumes.NotNull(cloneAsyncMethod);
108-
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, default(CancellationToken), null };
93+
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, null, null };
10994
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);
11095

11196
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home

src/GitHub.TeamFoundation.15/GitHub.TeamFoundation.15.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
<Reference Include="Microsoft.VisualStudio.Shell.Framework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
9696
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Framework.15.4.27004\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll</HintPath>
9797
<Private>True</Private>
98-
<Aliases>SF15</Aliases>
9998
</Reference>
10099
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
101100
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
@@ -104,7 +103,6 @@
104103
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
105104
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
106105
<Private>True</Private>
107-
<Aliases>global</Aliases>
108106
</Reference>
109107
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
110108
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>

src/GitHub.TeamFoundation.16/GitHub.TeamFoundation.16.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
<Reference Include="Microsoft.VisualStudio.Shell.Framework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
9696
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Framework.15.4.27004\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll</HintPath>
9797
<Private>True</Private>
98-
<Aliases>SF15</Aliases>
9998
</Reference>
10099
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
101100
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
@@ -104,7 +103,6 @@
104103
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
105104
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
106105
<Private>True</Private>
107-
<Aliases>global</Aliases>
108106
</Reference>
109107
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
110108
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,22 +605,19 @@
605605
<Private>True</Private>
606606
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIX>
607607
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIXLocalOnly>
608-
<Aliases>TF14</Aliases>
609608
</ProjectReference>
610609
<ProjectReference Include="..\GitHub.TeamFoundation.15\GitHub.TeamFoundation.15.csproj">
611610
<Project>{161dbf01-1dbf-4b00-8551-c5c00f26720e}</Project>
612611
<Name>GitHub.TeamFoundation.15</Name>
613612
<Private>True</Private>
614613
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIX>
615614
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIXLocalOnly>
616-
<Aliases>TF15</Aliases>
617615
</ProjectReference>
618616
<ProjectReference Include="..\GitHub.TeamFoundation.16\GitHub.TeamFoundation.16.csproj">
619617
<Project>{F08BD4BC-B5DF-4193-9B01-6D0BBE101BD7}</Project>
620618
<Name>GitHub.TeamFoundation.16</Name>
621619
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIX>
622620
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIXLocalOnly>
623-
<Aliases>TF16</Aliases>
624621
</ProjectReference>
625622
<ProjectReference Include="..\GitHub.UI.Reactive\GitHub.UI.Reactive.csproj">
626623
<Project>{158b05e8-fdbc-4d71-b871-c96e28d5adf5}</Project>

src/GitHub.VisualStudio/Services/VSGitExtFactory.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
extern alias TF14;
2-
extern alias TF15;
3-
extern alias TF16;
4-
5-
using System;
1+
using System;
62
using GitHub.Logging;
3+
using GitHub.VisualStudio.Base;
74
using Serilog;
8-
using VSGitExt14 = TF14.GitHub.VisualStudio.Base.VSGitExt;
9-
using VSGitExt15 = TF15.GitHub.VisualStudio.Base.VSGitExt;
10-
using VSGitExt16 = TF16.GitHub.VisualStudio.Base.VSGitExt;
115

126
namespace GitHub.Services
137
{

test/GitHub.VisualStudio.UnitTests/GitHub.VisualStudio.UnitTests.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
<Compile Include="..\Helpers\SplatModeDetectorSetUp.cs" />
1313
<Compile Include="..\Helpers\TestBaseClass.cs" />
1414
</ItemGroup>
15-
15+
1616
<ItemGroup>
17-
<ProjectReference Include="..\..\src\GitHub.TeamFoundation.15\GitHub.TeamFoundation.15.csproj">
18-
<Aliases>TF15</Aliases>
19-
</ProjectReference>
17+
<ProjectReference Include="..\..\src\GitHub.TeamFoundation.15\GitHub.TeamFoundation.15.csproj" />
2018
<ProjectReference Include="..\..\src\GitHub.VisualStudio\GitHub.VisualStudio.csproj" />
2119
</ItemGroup>
2220

0 commit comments

Comments
 (0)