c# - Does Conditional attribute eliminate subexpressions too? -


i have c/c++ background. put heavy assertions on code, , in c or c++ there's no guaranteed way eliminate evaluation of subexpressions assertion parameter. had use macro.

in c#, don't have level of macro support. have conditional attribute. in experience c , c++, subexpressions cannot eliminated due side-effects.

for example,

[conditional(debug)] void func1(int a) {     //  something. } int func2() {     //  called? }  func1(func2()); 

if func2 still being called, should code isdebugmode() && func1(func2()). want avoid. want know conditional attribute guarantees elimination of subexpressions or not.

if doesn't, what's best practice write debug build assertion stripped @ release build?

afaik, compiler specific support. want know case of mono compiler.

func2 won't called. stated in c# language specification mono compiler must act according these rules.

msdn http://msdn.microsoft.com/en-us/library/aa664622(v=vs.71).aspx:

the attribute conditional enables definition of conditional methods. conditional attribute indicates condition testing conditional compilation symbol. calls conditional method either included or omitted depending on whether symbol defined @ point of call. if symbol defined, call included; otherwise, call (including evaluation of parameters of call) omitted.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -