are bits of code used on by Assert included in builds?

example this:


the first assert inlines the formula, the others use a write var, which bit get inluded in a non dev build?

You can produce a non-development build and then use a tool like dnSpy or ILSpy to inspect the output assemblies (such as *_Data/Managed/Assembly-CSharp.dll) to see what is compiled.

According to the doc they included only in Editor, development build or if you manually add UNITY_ASSERTIONS define.
Take a look at Unity - Scripting API: Assert

I saw that, doc says the assert doesn’t get included, what about the line with the variable? no idea how a compilo works and if it auto inlines that stuff

oh sorry, didn’t get question right :slight_smile:

when you inline parameter calculation in conditional method call then parameter calculation will be removed from final build.

but in case you save calculation to variable and then call conditional method - parameters calculation will not be removed.
at least if parameters calculation is method call.

so in your example all calculation of count variable will be executed in release build, but calculation of first Assert parameters will be removed.

Take a look at this this stackoverflow answer
https://stackoverflow.com/a/21935537

1 Like

oh I see, so even through the variable is used nowhere else but in assert, the compilo keeps it in non dev build. good to know.