开发者

How to set breakpoints on lines that match a Task List token in Visual Studio?

开发者 https://www.devze.com 2022-12-16 21:37 出处:网络
This is neat: How do I put a breakpoint at every MessageBox in my application? But is there a way to do this type of thing for tokens in the Task List (View menu -> Task List) as well?

This is neat: How do I put a breakpoint at every MessageBox in my application?

But is there a way to do this type of thing for tokens in the Task List (View menu -> Task List) as well? For example, I have code like this:

int a=0; //RETEST this code
int b=0; //RETEST this code

In the above, RETEST is a Task List token; is there a way to set a breakpoint on all lines matching a certain Task List token quickly without having to go to each line where the token was found?

UPDATE

Here is the macro (inspired by How do I add Debug Breakpoints to lines displayed in a "Find Results" window in Visual Studio):

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.IO
Imports System.Text.RegularExpressions

Public Module CustomMacros
    Sub SetBreakpointsUsingTaskList()

        Dim TL As TaskList = DTE.ToolWindows.TaskList
    开发者_开发技巧    Dim TLItem As TaskItem

        For i = 1 To TL.TaskItems.Count
            TLItem = TL.TaskItems.Item(i)
            Try
                DTE.Debugger.Breakpoints.Add("", TLItem.FileName, TLItem.Line)
            Catch ex As Exception
                ' breakpoints can't be added everywhere
            End Try
        Next
    End Sub
End Module


Unfortunately no such precanned functionality exists in Visual Studio. It would likely be possible to do with a Macro.

0

精彩评论

暂无评论...
验证码 换一张
取 消