G-Man
G-Man

Reputation: 7241

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?

Upvotes: 4

Views: 467

Answers (1)

user585968
user585968

Reputation:

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.

Upvotes: 11

Related Questions