问题
My version is Visual Studio 2019, but this has been a issue for decades for me.
I have long debugging sessions by enabling/disabling breakpoints. In a short time, this will result in hundreds of irrelevant disabled breakpoints.
The breakpoint window doesn't seem to have an option to remove all disabled breakpoints. It can't even sort on the enabled column so I can manually delete them en masse.
I currently shift click my way through the disabled breakpoints in the grid, which kinda sucks because I'll have many screens of breakpoints with enabled rows peppered throughout it. A simple sort would make this a two click move.
Anyone have a clever way to do this? Or perhaps a better debugging practice of quickly switching between relevant breakpoints?
回答1:
You can use the following command (language C#) for my Visual Commander extension to remove all disabled breakpoints:
using EnvDTE;
using EnvDTE80;
using System.Linq;
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
DTE.Debugger.Breakpoints.Cast<Breakpoint>().Where(i => !i.Enabled).ToList().ForEach(i => i.Delete());
}
}
来源:https://stackoverflow.com/questions/65342545/remove-all-disabled-breakpoints-in-visual-studio