Any reason not to include CODE_ANALYSIS in the assembly?

Are there any performance costs if static code analysis is included in the assembly (release)?

Our CI server starts code analysis based on the debugging of our C # projects, while static code analysis is disabled in the release build (i.e., CODE_ANALYSIS is undefined). If there is no reason to disable code analysis on assemblies, then I spend time assembling debugging.

The reflector shows that attributes are SuppressMessageexcluded if code analysis is disabled, but I do not expect the additional attribute to affect runtime performance. Is this the only effect that allows static code analysis (in Visual Studio 2013)?

+4
source share
1 answer

There are real differences when compiling with a keyword CODE_ANALYSIS, for example, the compiler will remove all attributes [SuppressMessage]from the assembly when it is not turned on (and thus, messages may appear when FxCop starts later from the command line, since the locks have been removed). If you install your binaries in the internal system, suppression in binaries may be stopped. Some companies want them to be removed from meetings issued to third parties, since the presence of these attributes (and the contents of the rationale properties) may reveal confidential information.

DEBUG , , RELEASE, FxCop. ( inline) . FxCop , . .

: Debug. CODE_ANALYSIS Release.

+6

Source: https://habr.com/ru/post/1530250/


All Articles