How can I strip out all calls to an assembly during build?
Hello, I use a 3rd-party library a lot to validate the correctness of my code (FluentAssertions). However, when I build, I am confident my code is correct and want to strip out all calls to this library.
I know I can use compiler guards such as #if UNITY_EDITOR
around each call, or I can write a custom class myself that wraps the library and decorate each and every single call with [Conditional("UNITY_EDITOR")]
. However, I don't like either of these options since I either have to litter my code with compiler directives or wrap each and every function in the library with really simple, repetitive code.
For example, calls to System.Debug.Assert()
get stripped out of builds in Release mode.
Is there a way to tell Unity to strip all calls from a specific assembly or library out of the code at build time?