Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DEBUG vs RELEASE and distributing Assembly

I am creating and distributing an assembly for other developers to use. I am distributing the Release version of my assembly (not the debug). In one of the classes of my assembly, I have code set to run only in Debug mode using

#if DEBUG
    Console.WriteLine("Debug");
#else
    Console.WriteLine("Release");
#endif

If other developers reference my Assembly from their project and run their project in Debug mode, will my Debug only conditional run or not?

like image 324
G-Man Avatar asked Dec 24 '22 22:12

G-Man


1 Answers

If other developers reference my Assembly from their project and run their project in Debug mode, will my Debug only conditional run or not ?

No, because the Console.WriteLine() was never compiled in Release mode due to the pre-processor constraint.

MSDN has more to say on this:

When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified symbol is defined ... Tell me more...

Also, it's not correct to think of it as being removed from the assembly as it was never present in the first place.

like image 117
MickyD Avatar answered Jan 05 '23 03:01

MickyD