Just like any software development company, the individual teams at Microsoft frequently find themselves needing to cut features for the sake of shipping their product.  If we don't do this, an incurable and contageous mood altering phenomenon called needitnowosis develops in one or more disgruntled users but quickly spreads throughout the entire community.  The only known treatment for this disease is phewweshippeditcillintm (Microsoft Corp) .

Many users simply recover from their symptoms for a few years before succombing to the symptoms again.  Others, start to recover, only to fall into a worse condition called butwhataboutXfeaturism.

Oh I realize that not everyone has the sophisticated medical background I have, so in laymen's terms, “shipping“ becomes THE FEATURE all users request more than any other.  Decisions have to be made as to what stays and goes so that shipping can be our only focus.  Some users will wish our product had that feature X that didn't avoid the cut list.

Fortunately, Visual Studio 2003 sports an extensive automation model that can be used to “create“ that feature you might be missing.  Of course, having to write more programs to do your development probably isn't at the top of your todo list.  So I'd like to provide some useful macros for you to use as is or as a way to get you jump started. 

With that, here's my first entry.

Breakpoint Groups

Recently, and internal developer at Microsoft asked if the debugger had any feature that would allow him to easily switch between a set of breakpoints for a single project.  Unfortunately, there is no way to easily do that through any sort of user-interface mechanism.  It would likely wind up in a feature called Breakpoint Groups that may someday get shipped.  But all is not lost.  By creating the following macros and aliases, a similar feature can be created.  Better yet, if it doesn't quite suit your needs you can modify it to your heart's content.

Add the following two macros to the MyMacros project inside Visual Studio 2003.  You can access the MyMacros project  by:

  1. Choose the “Tools.Macros.Macros Explorer...” menu item.
  2. If you've never used this capability before you should see a new toolwindow with a treeview in it.  There will be two nodes listed under the Macros root node, “MyMacros“ and “Samples“.
  3. Expand “MyMacros”, right click on “Module1“ and choose “Edit“.
  4. A new IDE will open that  appears astonishingly like the Visual Studio IDE you're used to.  It actually IS running much of the same code but it is limited in that it only supports writing, running and debugging macros.  Macros are currently written in VB (but with some finagling you can access the automation model using any language, if it doesn't need to be a macro).  The IDE supports everything you'd expect when doing VB development, namely Intellisense.  This feature allows even VB newbies to make quick and easy progress.
  5. Copy and paste the macros that appear at the end of this posting into the definition of Module1.
  6. Now, switch back to the orginal VS IDE you started in and open the command window (View.Other Windows.Command Window).
  7. Enter the following two commands into the command window.  These aliases give you quick access to these two macros.
    • alias tagbps Macros.MyMacros.Module1.TagEnabledBreakpoints
    • alias enablebps Macros.MyMacrosModule1.EnableTaggedBreakpoints
  8. You're pretty much ready to group some bps at this point!  Set and enable some breakpoints, and open the breakpoints window (Debugger.Windows.Breakpoints)
  9. Disable one or more of your new breakpoints and type the following into the command window.
    • tagbps MyGroupOfBps1
  10. Now enable/disable a different set of breakpoints in the breakpoint window and type the following command:
    • tagbps MyGroupOfBps2
  11. To enable each breakpoint group, you can just enter one of the following commands whenever you please:
    • enablebps MyGroupOfBps1
    • enablebps MyGroupOfBps2

Here's the macros!  I hope you find these useful.  If you make some cool modifications or come up with some other useful macros, feel free to post them here!  Oh, remember that “Samples“ node I kinda ignored at step 2?  You might want to check it out now too. 

Sub TagEnabledBreakpoints(Optional ByRef strTag As String = "Tag1")

 
     Dim bps As EnvDTE.Breakpoints
     bps = DTE.Debugger.Breakpoints
If (bps.Count > 0) Then
    Dim bp As EnvDTE.Breakpoint
    For Each bp In bps
        If (bp.Enabled = True) Then
            bp.Tag = strTag
        End If
    Next
Else
    System.Windows.Forms.MessageBox.Show("Can't find any breakpoints to tag")
End If
End Sub
 
 
Sub EnableTaggedBreakpoints(Optional ByRef strTag As String = "Tag1")
    Dim bps As EnvDTE.Breakpoints
    bps = DTE.Debugger.Breakpoints
    If (bps.Count > 0) Then
        Dim bp As EnvDTE.Breakpoint
        For Each bp In bps
            If (bp.Tag = strTag) Then
                bp.Enabled = True
            Else
                bp.Enabled = False
            End If
        Next
    Else
        System.Windows.Forms.MessageBox.Show("Can't find any breakpoints to enable")
    End If
End Sub