Friday, June 13, 2008

VS 2008 Tracepoints – Debug output without touching your code (Say goodbye to Debug.Write ?)

Sara Ford's WebLog - Did you know… You can use Tracepoints to log “printf” or “console.writeline” info without editing your code? - #237

“This is a new feature for VS2008.

On a given line of code where you want to log the value of a variable, you could do the old fashion way of doing a Console.Writeline() or a PrintF().  But in VS 2008, there’s a new feature called tracepoints.

Just right-click, select breakpoints, but instead of Insert Breakpoint, select Insert Tracepoint.

Insert Tracepoints from Context Menu

This will bring up the Tracepoint dialog, where VS gives you some helpful defaults.  But for this example, the really helpful default is in the descriptive text for logging the contents of a variable.

Tracepoints dialog

You’ll notice that the editor shows a diamond instead of a circle.

Tracepoints indicated by a diamond

And the tracepoints are logged in the Output Window’s Debug Pane

Debug Window Output Pane logs tracepoints[Post leached in full as I couldn’t think of a way to summarize/truncate it well and wanted to make sure everyone got the full impression of it]

Now that’s fricken cool.

Sigh… another day, another realization of how little I know…

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...