如何在 Visual Studio 中与任务列表标记匹配的行上设置断点?
这很整洁: 如何在每个位置放置一个断点我的应用程序中的 MessageBox?
但是有没有办法对任务列表中的令牌(“查看”菜单 ->“任务列表”)执行此类操作? 例如,我有这样的代码:
int a=0; //RETEST this code
int b=0; //RETEST this code
在上面,RETEST 是一个任务列表标记;有没有一种方法可以快速在与某个任务列表标记匹配的所有行上设置断点,而不必转到找到该标记的每一行?
更新
这是宏(灵感来自如何将调试断点添加到 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,Visual Studio 中不存在这样的预装功能。可能可以使用宏来完成。
Unfortunately no such precanned functionality exists in Visual Studio. It would likely be possible to do with a Macro.