We recommend using Visual Studio 2017

CA1809: Avoid excessive locals


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CA1809: Avoid excessive locals.

|Breaking Change|Non-breaking|

A member contains more than 64 local variables, some of which might be compiler-generated.

A common performance optimization is to store a value in a processor register instead of in memory, which is referred to as enregistering the value. The common language runtime considers up to 64 local variables for enregistration. Variables that are not enregistered are put on the stack and must be moved to a register before manipulation. To allow the chance that all local variables get enregistered, limit the number of local variables to 64.

To fix a violation of this rule, refactor the implementation to use no more than 64 local variables.

It is safe to suppress a warning from this rule, or to disable the rule, if performance is not an issue.

CA1804: Remove unused locals