Conditional DEBUG - still compiling to RELEASE code?

I know that if I mark the code as DEBUG code, it will not work in RELEASE mode, but it will still be compiled into the assembly? I just want to make sure my build is not bloated with additional methods.

[Conditional(DEBUG)]
private void DoSomeLocalDebugging()
{
   //debugging
}
+5
source share
1 answer

Yes, the method itself is still built, but you are compiling.

This is completely logical - since the point Conditionalshould depend on the symbols of the preprocessor defined when creating the caller, and not when building the called party.

A simple test - build this:

using System;
using System.Diagnostics;

class Test
{
    [Conditional("FOO")]
    static void CallMe()
    {
        Console.WriteLine("Called");
    }

    static void Main()
    {
        CallMe();
    }
}

( FOO), , , Reflector, , .

, , .NET (, ) DEBUG? ( , !), Debug.Assert ..?

, , , , , , .

+10

All Articles