The Debug
and Trace
classes have very similar methods. The primary difference is that calls to the Debug
class are typically only included in Debug build and Trace are included in all builds (Debug and Release). You can control this through the compiler flags DEBUG and TRACE. If you look at the documentation for both, you will notice the ConditionalAttribute
annotating the methods. This causes the method calls to be included in the binaries only when the appropriate compiler flag is defined. You could define your own compiler flag and use it in conjunction with the ConditionalAttribute
in a similar fashion. Note that if you use this, the methods are not removed from the compiled binaries. The call sites are modified to remove the method calls.