I know that if I mark code as DEBUG code it won’t run in RELEASE mode, but does it still get compiled into an assembly? I just wanna make sure my assembly isn’t bloated by extra methods.
[Conditional(DEBUG)]
private void DoSomeLocalDebugging()
{
//debugging
}
Yes, the method itself still is built however you compile.
This is entirely logical – because the point of
Conditionalis to depend on the preprocessor symbols defined when the caller is built, not when the callee is built.Simple test – build this:
Run the code (without defining FOO) and you’ll see there’s no output, but if you look in Reflector you’ll see the method is still there.
To put it another way: do you think the .NET released assemblies (the ones we compile against) are built with the DEBUG symbol defined? If they’re not (and I strongly suspect they’re not!) how would we be able to call
Debug.Assertetc?Admittedly when you’re building private methods it would make sense not to include it – but as you can see, it still is built – which is reasonable for simplicity and consistency.