Remove all disabled breakpoints in Visual Studio

扶醉桌前 提交于 2021-01-07 06:58:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!