Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConditionalAttribute on Main()

Tags:

c#

This is a question out of curiousity. I was messing around with some code, and realized that the following still compiles in release:

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

I thought ConditionalAttribute was supposed to wipe out the method, but it doesn't. What's special about the entry point?

like image 424
Marlon Avatar asked Dec 29 '22 00:12

Marlon


1 Answers

I believe it wipes out the calls to the method, not the method itself. Main is never (or should never be) called from your code, so this won't change anything.

like image 105
user541686 Avatar answered Dec 30 '22 14:12

user541686