使用VS2010
ANSWER 感谢汉斯(因为我很难回答我自己的问题8小时)
Sub CreateBreakPoint()
Dim doc As TextDocument = _
CType(DTE.ActiveDocument.Object("TextDocument"), TextDocument)
Dim point As EditPoint = doc.StartPoint.CreateEditPoint
While point.NextBookmark()
Try
point.ClearBookmark()
DTE.Debugger.Breakpoints.Add("", DTE.ActiveDocument.FullName, point.Line(), 1, "", dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, "c#", "", 0, "", 0, dbgHitCountType.dbgHitCountTypeNone)
Catch ex As Exception
MsgBox("error: " + ex.Message)
End Try
End While
MsgBox("Done")
End Sub
我有一个宏,它会在每个书签上设置断点。它起作用(像一个大锤)......但出于好奇我如何做以下其中一个以便我可以使用“正确的”For Loop
当前代码
Public Module BookMarksToBreakPoints
Sub TemporaryMacro()
Dim bookmarkWin As Window = DTE.Windows.Item(WindowKinds.vsWindowKindBookmarks)
While True
Try
DTE.ExecuteCommand("Edit.NextBookmark")
DTE.ExecuteCommand("Edit.ToggleBookmark")
DTE.ExecuteCommand("Debug.ToggleBreakpoint")
Catch e As Exception
MsgBox("Done")
Exit While
End Try
End While
End Sub
End Module
答案 0 :(得分:1)
感谢Hans Passant推动正确的方向发展。最后的宏:
Sub CreateBreakPoint()
Dim doc As TextDocument = _
CType(DTE.ActiveDocument.Object("TextDocument"), TextDocument)
Dim point As EditPoint = doc.StartPoint.CreateEditPoint
While point.NextBookmark()
Try
point.ClearBookmark()
DTE.Debugger.Breakpoints.Add("", DTE.ActiveDocument.FullName, point.Line(), 1, "", dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, "c#", "", 0, "", 0, dbgHitCountType.dbgHitCountTypeNone)
Catch ex As Exception
MsgBox("error: " + ex.Message)
End Try
End While
MsgBox("Done")
End Sub