如何在Visual Studio 2015的“查找结果"窗口中显示的行上添加调试断点 [英] How do I add Debug Breakpoints to lines displayed in a “Find Results” window in Visual Studio 2015
问题描述
以前,对于Visual Studio(VS)的先前版本,已回答此问题.所提供的解决方案涉及宏,而VS 2015中不再提供这些宏.我能否获得VS 2015的解决方案?
This question was answered before for a previous version of Visual Studio (VS). The offered solutions involved macros, which are no longer available in VS 2015. Could I get a solution for VS 2015?
我想在VS中进行查找全部"操作,并在查找匹配的每一行上放置一个调试断点.
I would like to do a "find all" in VS and put a debug-breakpoint on every line with a find match.
链接到诺亚问的上一个问题: 如何操作我将调试断点添加到显示在查找结果"行中的行中. Visual Studio中的窗口
Link to previous question asked by Noah: How do I add Debug Breakpoints to lines displayed in a "Find Results" window in Visual Studio
推荐答案
I've converted the old macro to a VB command in Visual Commander (by adding explicit namespaces to classes):
Public Class C
Implements VisualCommanderExt.ICommand
Sub Run(DTE As EnvDTE80.DTE2, package As Microsoft.VisualStudio.Shell.Package) Implements VisualCommanderExt.ICommand.Run
Dim findResultsWindow As EnvDTE.Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindFindResults1)
Dim selection As EnvDTE.TextSelection
selection = findResultsWindow.Selection
selection.SelectAll()
Dim findResultsReader As New System.IO.StringReader(selection.Text)
Dim findResult As String = findResultsReader.ReadLine()
Dim findResultRegex As New System.Text.RegularExpressions.Regex("(?<Path>.*?)\((?<LineNumber>\d+)\):")
While Not findResult Is Nothing
Dim findResultMatch As System.Text.RegularExpressions.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 System.Exception
' breakpoints can't be added everywhere
End Try
End If
findResult = findResultsReader.ReadLine()
End While
End Sub
End Class
这篇关于如何在Visual Studio 2015的“查找结果"窗口中显示的行上添加调试断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!