ConditionalAttribute on Main ()

This is a question of curiosity. I was messing around with some code and realized that the release is still compiling:

class Program
{
    [Conditional("DEBUG")]
    private static void Main()
    {
        // do stuff
    }
}

I thought ConditionalAttribute should have destroyed the method, but that is not the case. What is special about the entry point?

+3
source share
1 answer

I believe that it destroys method calls, not the method itself. Mainnever (or should never be) called from your code, so this will not change anything.

+9
source

Source: https://habr.com/ru/post/1795014/


All Articles