A question came up on an internal DL about checking if an assembly was debug or release.  I’m always looking for something to spout about, and this seemed like a good one.

 

There are 3 things people typically identify as the difference between debug & release.  You need to decide which one you’re interested in:

 

“DEBUG” preprocessor flag. Can be set on the whole assembly/netmodule with ‘csc /define’, or on a whole file with #define. 

 

Debugging information (pdb).  Set with ‘csc /debug[+|-]’.   It doesn’t affect codegen, so it’s really not very interesting.

 

Optimization.  Set with ‘csc /optimize[+|-]’.  In managed code, the JITter in the runtime does nearly all the optimization.  The difference in generated IL from this flag is pretty small.  The Whidbey C# compiler has more a difference on this flag than previous versions, but it’s still not much.

 

I don’t know of a way to ask what preprocessor flags were set for compiling a bit of code, but I would start my search by thinking about how they are applied at the file and assembly/netmodule scopes.