Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional attribute and calculated arguments for method [duplicate]

I have code like this in my code

Debug.WriteLine($@"Operation time: {elapsedMilliseconds}ms");

Write line marked with [Conditional("DEBUG")], that means that calls of this method will be omitted in release.

[Conditional("DEBUG")]
[__DynamicallyInvokable]
public static void WriteLine(string message, string category)
{
  TraceInternal.WriteLine(message, category);
}

But, will it call string.Format for argument of this method in RELEASE or remove it too?

like image 711
Yuiry.Vasilyev Avatar asked Sep 11 '25 09:09

Yuiry.Vasilyev


1 Answers

Found answer here - Does using ConditionalAttribute also remove arguments computation?

If the symbol is defined, the call is included; otherwise, the call (including evaluation of the parameters of the call) is omitted.

like image 151
Yuiry.Vasilyev Avatar answered Sep 13 '25 22:09

Yuiry.Vasilyev