The adventure of writing meaningful code.
Conditional Debug mode
Sometimes we have to implement code that is only meant to work for us as developers and not the our clients. That is when conditional debug comes to play. Using conditional debug it is possible to only allow some functions to be called only if the project is running in debug mode.
I found it useful on the following scenarios:
- Impersonation – change my context to a specific user contex.
- Tracing/Profiling
- Testing
[Conditional("DEBUG")]
public void OnlyRunIfUnderDebug(string person)
{
//replace context with person's arguments context
//profiling
//testing
//etc
}
| Print article | This entry was posted by dan on October 8, 2009 at 1:53 pm, and is filed under C#. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |