Skip to content

Commit ce1d3e9

Browse files
author
Maria Solano
committed
Add open solution check
1 parent 9c32305 commit ce1d3e9

File tree

1 file changed

+7
-0
lines changed
  • src/toolkit/Community.VisualStudio.Toolkit.Shared/Solution

1 file changed

+7
-0
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/Solution/Solutions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using System.Threading.Tasks;
6+
using Microsoft.Internal.VisualStudio.PlatformUI;
67
using Microsoft.VisualStudio;
78
using Microsoft.VisualStudio.Shell;
89
using Microsoft.VisualStudio.Shell.Interop;
@@ -24,6 +25,12 @@ internal Solutions()
2425
public async Task<Solution?> GetCurrentSolutionAsync()
2526
{
2627
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
28+
29+
if (!HierarchyUtilities.IsSolutionOpen)
30+
{
31+
return null;
32+
}
33+
2734
IVsHierarchy solution = (IVsHierarchy)await VS.Services.GetSolutionAsync();
2835
IVsHierarchyItem hierItem = await solution.ToHierarchyItemAsync(VSConstants.VSITEMID_ROOT);
2936
return SolutionItem.FromHierarchyItem(hierItem) as Solution;

0 commit comments

Comments
 (0)