Quote:
> Hi All,
> I was just wondering if anyone could tell me whether or not the C#
compiler
> contains an optimiser?
> I want to create a number of modules in C#, the way I have always done it
> (in the past) using C is to leave the test stubs in so they can be re-used
> later if required. The optimiser would then remove this redundant code
when
> not in use.
> Can I do the same in C#?
The C# contains some optimization, but I'm not sure exactly what it does.
What you're looking to do involves compiler directives.
Generally, people have two types of compiles: DEBUG and RELEASE.
What you'd do is put a compiler conditional around your test stubs
so that when the DEBUG compiler directive is set, it WILL compile
the stubs, but when it's set to RELEASE, it WON'T compile.
#if DEBUG
/* Do test stub stuf here */
#endif
See the .NET Framework SDK on "#if preprocessor directive".
Also, I'd like to point out that, generally, it's bad practice
to modify classes for special testing functions. What you
should do is leave the class whole and in-tact, and then
write seperate test classes that test the public or
internal members of the class.
-c