Skip to content

Commit

Permalink
Ensures Resharper does not hang Visual Studio
Browse files Browse the repository at this point in the history
When VsChromium indexes a large project, and "Solution Explorer" is enabled,
Resharper enumerates all entries (directories and files, recursively) shown
in Solution Explorer. For large projects, there can be hundred of thousand
directories, and even more files.

Resharper behavior leads to hangs in Visual Studio UI, because all
programmatic access to the Solution Explorer nodes happens on the UI
thread (IvsHierarchy).

This change implements a workaround in IVsHierarchy implementation
of Solution Explorer: If Resharper extension is detected in the list
of calling methods, we return E_NOTIMPL. This is clearly brittle, but
we could not figure out a better way.

This fixes issue #68
  • Loading branch information
rpaquay committed Jun 9, 2020
1 parent 0fedc90 commit 5be7c8e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/VsChromium/Features/SourceExplorerHierarchy/NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using VsChromium.Core.Files;
Expand Down Expand Up @@ -134,6 +135,10 @@ public int GetProperty(int propid, out object pvar) {
break;
case (int)__VSHPROPID.VSHPROPID_FirstVisibleChild:
case (int)__VSHPROPID.VSHPROPID_FirstChild:
// Special to prevent Visual Studio hangs when Resharper calls into Solution Explorer
if (this is RootNodeViewModel && IsResharperCaller()) {
return VSConstants.E_NOTIMPL;
}
pvar = GetFirstChildItemId();
break;
case (int)__VSHPROPID.VSHPROPID_Expanded:
Expand Down Expand Up @@ -201,6 +206,11 @@ public int GetProperty(int propid, out object pvar) {
protected abstract IList<NodeViewModel> ChildrenImpl { get; }
protected abstract bool IsExpandable { get; }

private static bool IsResharperCaller() {
var stackTrace = new StackTrace().ToString();
return stackTrace.Contains("JetBrains.VsIntegration.");
}

private void AppendFullPath(StringBuilder sb) {
if (string.IsNullOrEmpty(Name))
return;
Expand Down

0 comments on commit 5be7c8e

Please sign in to comment.