Skip to content

Commit a1199b4

Browse files
committed
Removed dependency to Microsoft.VisualStudio.ProjectSystem from the VisualStudioHelperService
1 parent e6c6010 commit a1199b4

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

SmartCmdArgs/SmartCmdArgs.Shared/Helper/CpsProjectSupport.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
using System.Linq;
99
using System.Threading.Tasks.Dataflow;
1010

11+
// This isolation of Microsoft.VisualStudio.ProjectSystem dependencies into one file ensures compatibility
12+
// across various Visual Studio installations. This is crucial because not all Visual Studio workloads
13+
// include the ManagedProjectSystem extension by default. For instance, installing Visual Studio with only
14+
// the C++ workload does not install this extension, whereas it's included with the .NET workload at
15+
// "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\ManagedProjectSystem".
16+
// One might consider adding the Microsoft.VisualStudio.ProjectSystem assembly to the VSIX. However, this approach fails due to
17+
// Visual Studio's configuration file (located at "%userprofile%\AppData\Local\Microsoft\VisualStudio\17.0_xxxxxxxx\devenv.exe.config")
18+
// specifying a binding redirect for Microsoft.VisualStudio.ProjectSystem.Managed to the latest version.
19+
// As such, ensuring compatibility requires knowledge of the version Visual Studio redirects to, which varies
20+
// by Visual Studio installation version.
21+
1122
namespace SmartCmdArgs.Helper
1223
{
1324
public static class CpsProjectSupport
@@ -64,7 +75,7 @@ public static IEnumerable<string> GetLaunchProfileNames(EnvDTE.Project project)
6475
return null;
6576
}
6677

67-
public static IDisposable ListenToLaunchProfileChanges(EnvDTE.Project project, Action<ILaunchSettings> listener)
78+
public static IDisposable ListenToLaunchProfileChanges(EnvDTE.Project project, Action listener)
6879
{
6980
if (TryGetProjectServices(project, out IUnconfiguredProjectServices unconfiguredProjectServices, out IProjectServices projectServices))
7081
{
@@ -74,7 +85,7 @@ public static IDisposable ListenToLaunchProfileChanges(EnvDTE.Project project, A
7485
return null;
7586

7687
return launchSettingsProvider.SourceBlock.LinkTo(
77-
new ActionBlock<ILaunchSettings>(listener),
88+
new ActionBlock<ILaunchSettings>(_ => listener()),
7889
new DataflowLinkOptions { PropagateCompletion = true });
7990
}
8091

SmartCmdArgs/SmartCmdArgs.Shared/Services/VisualStudioHelperService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using EnvDTE;
22
using Microsoft.VisualStudio;
3-
using Microsoft.VisualStudio.ProjectSystem.Debug;
43
using Microsoft.VisualStudio.Shell;
54
using Microsoft.VisualStudio.Shell.Interop;
65
using SmartCmdArgs.Helper;
@@ -123,7 +122,7 @@ class ProjectState : IDisposable
123122

124123
private IDisposable _launchSettingsChangeListenerDisposable;
125124

126-
public ProjectState(IVsHierarchyWrapper pHierarchy, Action<ILaunchSettings> launchProfileChangeAction)
125+
public ProjectState(IVsHierarchyWrapper pHierarchy, Action launchProfileChangeAction)
127126
{
128127
ProjectDir = pHierarchy.GetProjectDir();
129128
ProjectName = pHierarchy.GetName();
@@ -188,7 +187,7 @@ private void AddProjectState(IVsHierarchyWrapper pHierarchy)
188187
{
189188
Guid projectGuid = pHierarchy.GetGuid();
190189
ProjectStateMap.GetValueOrDefault(projectGuid)?.Dispose();
191-
ProjectStateMap[projectGuid] = new ProjectState(pHierarchy, profile =>
190+
ProjectStateMap[projectGuid] = new ProjectState(pHierarchy, () =>
192191
{
193192
ThreadHelper.JoinableTaskFactory.Run(async () =>
194193
{

0 commit comments

Comments
 (0)