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

Commit fc06da7

Browse files
committed
Use ApplicationInfo.GetHostVersionInfo not DTE.Version
1 parent af9f364 commit fc06da7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ async Task<object> CreateService(IAsyncServiceContainer container, CancellationT
261261
}
262262
else if (serviceType == typeof(IVSGitExt))
263263
{
264-
return await VSGitExtFactory.Create(this);
264+
var vsVersion = ApplicationInfo.GetHostVersionInfo().FileMajorPart;
265+
return VSGitExtFactory.Create(vsVersion, this);
265266
}
266267
else if (serviceType == typeof(IGitHubToolWindowManager))
267268
{

src/GitHub.VisualStudio/Services/VSGitExtFactory.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
extern alias TF15;
33

44
using System;
5-
using System.Threading.Tasks;
65
using System.ComponentModel.Composition;
6+
using GitHub.Info;
77
using GitHub.Logging;
88
using Serilog;
9-
using EnvDTE;
109
using Microsoft.VisualStudio.Shell;
1110
using VSGitExt14 = TF14.GitHub.VisualStudio.Base.VSGitExt;
1211
using VSGitExt15 = TF15.GitHub.VisualStudio.Base.VSGitExt;
@@ -24,19 +23,16 @@ public VSGitExtFactory(IGitHubServiceProvider serviceProvider)
2423
VSGitExt = serviceProvider.GetService<IVSGitExt>();
2524
}
2625

27-
public async static Task<IVSGitExt> Create(IAsyncServiceProvider sp)
26+
public static IVSGitExt Create(int vsVersion, IAsyncServiceProvider sp)
2827
{
29-
var dte = await sp.GetServiceAsync(typeof(DTE)) as DTE;
30-
31-
// DTE.Version always ends with ".0" even for later minor versions.
32-
switch (dte.Version)
28+
switch (vsVersion)
3329
{
34-
case "14.0":
30+
case 14:
3531
return Create(() => new VSGitExt14(sp.GetServiceAsync));
36-
case "15.0":
32+
case 15:
3733
return Create(() => new VSGitExt15(sp.GetServiceAsync));
3834
default:
39-
log.Error("There is no IVSGitExt implementation for DTE version {Version}", dte.Version);
35+
log.Error("There is no IVSGitExt implementation for DTE version {Version}", vsVersion);
4036
return null;
4137
}
4238
}

0 commit comments

Comments
 (0)