Click here to Skip to main content
13,288,520 members (67,405 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.8K views
1 bookmarked
Posted 14 Oct 2011

Preventing stubbed methods from being released

, 15 Oct 2011
Rate this:
Please Sign up or sign in to vote.
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...
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 mode.
}
else
{
   // This code executes when starting from outside VS either in release or debug mode.
}

This looks more .NETish, but also performs differently as you can see.
I have used it many times for debugging purposes (for example, giving a value to a variable only for debugging).
Though not really a substitute for the above tips, I thought I should include this for completeness. :)

License

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

Share

About the Author

Sander Rossel
Software Developer (Senior)
Netherlands Netherlands
Sander Rossel is a professional developer since 2010 with working experience in .NET (VB and C#, WinForms, MVC, Web API, and Entity Framework), SQL Server, VSTS, JavaScript, Git, Jenkins, Oracle, and other technologies.
He has an interest in various technologies including, but not limited to, functional programming, NoSQL, software design, Continuous Integration, and software quality in general.

You can't miss his must read book Continuous Integration, Delivery, and Deployment!

He also wrote the +/- 100 page eBooks Object-Oriented Programming in C# Succinctly and SQL Server for C# Developers Succinctly.

And he wrote a JavaScript LINQ library, arrgh.js (works in IE8+, Edge, Firefox, Chrome, and probably everything else).

Check out his prize-winning articles here on CodeProject as well!

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralFor great effect, you can combine this with other useful met... Pin
Julien Villers15-Oct-11 3:00
memberJulien Villers15-Oct-11 3:00 
GeneralRe: Debugger.Break(), yeah. Use it from time to time when breakp... Pin
Naerling15-Oct-11 3:06
memberNaerling15-Oct-11 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 15 Oct 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid