Click here to Skip to main content
15,881,204 members
Articles / Programming Languages / C#

Preventing stubbed methods from being released

Rate me:
Please Sign up or sign in to vote.
4.96/5 (24 votes)
1 Sep 2011CPOL1 min read 39.2K   15  
A handy way to stub methods in development, but preventing them from being shipped in release mode.

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
14 Oct 2011Julien Villers
Nice tip! I'm also a proponent of using your friend the preprocessor to stop you from making big mistakes, along with your best friend, the compiler.You can combine both using this alternative code:private bool ValidateUserDetails(string userName, string password){ //TODO: Default value...
Please Sign up or sign in to vote.
15 Oct 2011Sander Rossel
Very nice tips indeed!A somewhat different approach to this might be to use the Debugger.IsAttached[^] static property.Though this works somewhat different.if (System.Diagnostics.Debugger.IsAttached){ // This code executes when starting from VS either in release or debug...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Program Manager
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions