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.

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

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.

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

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

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

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

VS 2008 Tracepoints – Debug output without touching your code (Say goodbye to Debug.Write ?)[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…

相关文章:

  • 2021-11-06
  • 2021-11-15
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2021-08-08
  • 2021-10-06
  • 2021-08-22
猜你喜欢
  • 2021-06-07
  • 2021-10-31
  • 2021-12-13
  • 2018-12-01
  • 2021-06-22
  • 2022-03-07
  • 2021-10-20
相关资源
相似解决方案