DoNotInitializeUnnecessarily
Name: Do not initialize unnecessarily
Level: Warning
Certainty: 90
File: Performance Rules
Category: Microsoft.Performance
Check Id: CA1805
Additional Information: Do not make initializations that have already been done by the runtime.
This rule asks that I comment out the line:
private System.ComponentModel.IContainer components = null;
In global.asax.cs for a web application. Doing this produces a compiler error,
'(Namespace).Global' does not contain a definition for 'components'
This rule appears to be incorrect in this instance.
As Paul notes, the issue here is the code that sets the declared reference to null. This is done by the runtime automatically, so the additional code in your destructor setting this variable (a second time) to null is unnecessary. This is an extremely local optimization that is unlikely to impact performance of a web app. For extremely performance sensitive code, unnecessary initializations have measurable impact (in fact, this rule was suggested to us by internal teams tuning very perf-sensitive API).
Other unnecessary initializations include setting primitive values (int, long, etc) to 0 or initializing a boolean to false. But again you should feel free to ignore or disable this rule if resolving this problem is unlikely to provide a measurable perf gain for your app.