DCSIMG
August 2010 - Posts - Bnaya Eshet

Bnaya Eshet

Disclaimer

August 2010 - Posts

T4 tip (debug)

T4 tip (debug)

while I was writing the post on T4 debugging (here),

I had show how to use System.Diagnostics.Debugger.Break()

in order of getting the debugger stop.

 

actually there is 2 problem with this pattern:

  • the break point remain active while no debugger is attached.
  • it cause VS to crash when ever saving the t4, when the debugger doesn't attached.
Solution

we can overcome those issues by changing the pattern to match the following:

Code Snippet
  1. if (System.Diagnostics.Debugger.IsAttached)
  2.     System.Diagnostics.Debugger.Break();

 

Summary

using the IsAttached pattern will prevent the breaking point activation

as long as the no debugger is attached.

 

kick it on DotNetKicks.com Shout it
Digg This
Posted: Aug 15 2010, 05:28 PM by bnaya
תגים:, , ,