gpt4 book ai didi

visual-studio - 如何在 Visual Studio 的 "Find Results"窗口中显示的行中添加调试断点

转载 作者:行者123 更新时间:2023-12-03 21:28:08 25 4
gpt4 key购买 nike

在 Visual Studio 2005-2015 中,可以找到包含某些引用的所有行并将它们显示在“查找结果”窗口中。

现在显示了这些结果行,是否有任何键盘快捷键可以向所有结果行添加调试断点?

最佳答案

此答案不适用于 Visual Studio 2015 或更高版本。可以找到更新的答案 here .

使用 Visual Studio 宏可以很容易地做到这一点。在 Visual Studio 中,按 Alt-F11 打开宏 IDE 并通过右键单击 MyMacros 并选择 Add|Add Module... 添加一个新模块

在源代码编辑器中粘贴以下内容:

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

Public Module CustomMacros
Sub BreakpointFindResults()
Dim findResultsWindow As Window = DTE.Windows.Item(Constants.vsWindowKindFindResults1)

Dim selection As TextSelection
selection = findResultsWindow.Selection
selection.SelectAll()

Dim findResultsReader As New StringReader(selection.Text)
Dim findResult As String = findResultsReader.ReadLine()

Dim findResultRegex As New Regex("(?<Path>.*?)\((?<LineNumber>\d+)\):")

While Not findResult Is Nothing
Dim findResultMatch As Match = findResultRegex.Match(findResult)

If findResultMatch.Success Then
Dim path As String = findResultMatch.Groups.Item("Path").Value
Dim lineNumber As Integer = Integer.Parse(findResultMatch.Groups.Item("LineNumber").Value)

Try
DTE.Debugger.Breakpoints.Add("", path, lineNumber)
Catch ex As Exception
' breakpoints can't be added everywhere
End Try
End If

findResult = findResultsReader.ReadLine()
End While
End Sub
End Module

此示例使用“查找结果 1”窗口中的结果;您可能希望为每个结果窗口创建一个单独的快捷方式。

您可以通过转到工具|选项...并选择 来创建键盘快捷键。键盘 环境 左侧导航中的部分。选择您的宏并分配您喜欢的任何快捷方式。

您还可以通过转到工具|自定义...并选择 来将宏添加到菜单或工具栏。宏 左侧导航中的部分。一旦你在列表中找到你的宏,你可以将它拖到任何菜单或工具栏,它的文本或图标可以自定义为你想要的任何东西。

关于visual-studio - 如何在 Visual Studio 的 "Find Results"窗口中显示的行中添加调试断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com