How do C#'s IIncrementalGenerators know if the compiler is doing an optimised build?

31 views Asked by At

I want to write an IIncrementalGenerator which has slightly different behaviour depending on if the compiler is doing a release or debug build. I know you in the CsProj you have the Optimize flag which controls some optimisations.

I want to check this Optimize flag during the Initialize call so that my generated code can perform more checks and generate more aggressive code which requires a lot more checks of the assembly. This isn't needed for debug builds as a simplified version of this can be generated which isn't as precise.

How do I get the state of Optimise or debug/release configurations in the Initialize call?

0

There are 0 answers