How do I add Debug Breakpoints to lines displayed in a “Find Results” window in Visual Studio 2015
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
If you have JetBrains Resharper and use one of Reharper's search commands, you can do this directly from Resharper's Find Results window (different from VS Find Results).
Example:
Resharper > Navigate > Go to Text... (Ctrl+T,T,T if using Resharper key map)
And then in Find Results (Resharper), right click any node or container in the tree view and choose "Set Breakpoint." This sets a breakpoint on all sub-nodes.
Reference:
https://blog.jetbrains.com/dotnet/2017/12/04/debugger-features-resharper/