From 48aef595fb065d8d374ccc17596fc9f89558902c Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Thu, 14 May 2026 11:17:51 -0400 Subject: [PATCH] fix(commands): refresh Solution Explorer after cleaning bin/obj Sends the standard Refresh command to each cleaned project's IVsUIHierarchy so stale nodes disappear from Solution Explorer without requiring an unload/reload, particularly under "Show All Files". --- .../Commands/SuperCleanCommand.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/CodingWithCalvin.SuperClean/Commands/SuperCleanCommand.cs b/src/CodingWithCalvin.SuperClean/Commands/SuperCleanCommand.cs index bbef494..55b2268 100644 --- a/src/CodingWithCalvin.SuperClean/Commands/SuperCleanCommand.cs +++ b/src/CodingWithCalvin.SuperClean/Commands/SuperCleanCommand.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using CodingWithCalvin.Otel4Vsix; using Community.VisualStudio.Toolkit; +using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; using MessageBox = System.Windows.Forms.MessageBox; namespace CodingWithCalvin.SuperClean.Commands @@ -232,8 +234,33 @@ async Task SuperCleanProjectAsync(SolutionItem project) projectActivity?.SetTag("obj.deleted", true); } + await RefreshInSolutionExplorerAsync(project); + return true; } } + + private static async Task RefreshInSolutionExplorerAsync(SolutionItem project) + { + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + + project.GetItemInfo(out IVsHierarchy hierarchy, out uint itemId, out _); + + if (hierarchy is not IVsUIHierarchy uiHierarchy) + { + return; + } + + var cmdGuid = VSConstants.GUID_VSStandardCommandSet97; + + uiHierarchy.ExecCommand( + itemId, + ref cmdGuid, + (uint)VSConstants.VSStd97CmdID.Refresh, + 0, + IntPtr.Zero, + IntPtr.Zero + ); + } } }