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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With