-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added VS 2022 support and fixed VS 2017 support.
- Loading branch information
1 parent
dc8419d
commit 3d84584
Showing
20 changed files
with
333 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace VSTabPath.Interop.Contracts | ||
{ | ||
// Since VS 17.0, many interop types were moved to different assemblies, so code interacting with them | ||
// must have diferent references for different VS versions. Such code was moved to proxy assemblies. | ||
public static class DteInteropResolver | ||
{ | ||
public static IDteInterop Interop { get; } | ||
|
||
static DteInteropResolver() | ||
{ | ||
var assemblyName = Environment.Is64BitProcess ? "VSTabPath.Interop.X64" : "VSTabPath.Interop.X86"; | ||
var assembly = Assembly.Load(assemblyName); | ||
var type = assembly.GetType("VSTabPath.Interop.DteInterop"); | ||
Interop = (IDteInterop)Activator.CreateInstance(type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace VSTabPath.Interop.Contracts | ||
{ | ||
public interface IDteInterop | ||
{ | ||
string GetSolutionRootPath(); | ||
|
||
event Action SolutionOpened; | ||
event Action<string> SolutionRenamed; | ||
event Action SolutionClosed; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
VSTabPath.Interop.Contracts/VSTabPath.Interop.Contracts.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<SignAssembly>True</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\VSTabPath\Key.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using EnvDTE; | ||
using EnvDTE80; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using VSTabPath.Interop.Contracts; | ||
|
||
namespace VSTabPath.Interop | ||
{ | ||
// ReSharper disable once UnusedMember.Global | ||
public class DteInterop : IDteInterop | ||
{ | ||
private readonly DTE2 _dte; | ||
|
||
public DteInterop() | ||
{ | ||
_dte = (DTE2)Package.GetGlobalService(typeof(SDTE)); | ||
} | ||
|
||
public string GetSolutionRootPath() | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
|
||
var solution = _dte.Solution; | ||
if (solution == null) | ||
return null; | ||
|
||
var fullName = solution.FullName; | ||
if (string.IsNullOrEmpty(fullName)) | ||
{ | ||
// A project has been opened without a solution, so a temporary one is created. | ||
// Use the project root path instead. | ||
fullName = solution.Projects.Cast<Project>().FirstOrDefault()?.FullName; | ||
} | ||
|
||
return string.IsNullOrEmpty(fullName) ? null : Path.GetDirectoryName(fullName); | ||
} | ||
|
||
public event Action SolutionOpened | ||
{ | ||
add => _dte.Events.SolutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(value); | ||
remove => _dte.Events.SolutionEvents.Opened -= new _dispSolutionEvents_OpenedEventHandler(value); | ||
} | ||
|
||
public event Action<string> SolutionRenamed | ||
{ | ||
add => _dte.Events.SolutionEvents.Renamed += new _dispSolutionEvents_RenamedEventHandler(value); | ||
remove => _dte.Events.SolutionEvents.Renamed -= new _dispSolutionEvents_RenamedEventHandler(value); | ||
} | ||
|
||
public event Action SolutionClosed | ||
{ | ||
add => _dte.Events.SolutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(value); | ||
remove => _dte.Events.SolutionEvents.AfterClosing -= new _dispSolutionEvents_AfterClosingEventHandler(value); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
VSTabPath.Interop.Shared/VSTabPath.Interop.Shared.projitems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>064a5ff7-b156-4165-9594-9867f5a5d382</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>VSTabPath.Interop</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)DteInterop.cs" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>064a5ff7-b156-4165-9594-9867f5a5d382</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="VSTabPath.Interop.Shared.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="EnvDTE80" Version="17.0.32112.339" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="17.0.32112.339" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\VSTabPath.Interop.Contracts\VSTabPath.Interop.Contracts.csproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="..\VSTabPath.Interop.Shared\VSTabPath.Interop.Shared.projitems" Label="Shared" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="EnvDTE80" Version="8.0.3" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.0.26606" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\VSTabPath.Interop.Contracts\VSTabPath.Interop.Contracts.csproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="..\VSTabPath.Interop.Shared\VSTabPath.Interop.Shared.projitems" Label="Shared" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.