When assigning a defualt default-value to a field (here false to a bool), fxcops says :
Resolution : "'Bar.Bar()' initializes field 'Bar.foo'
of type 'bool' to false. Remove this initialization
because it will be done automatically by the runtime."
Now, I know that code as int a = 0
or bool ok = false
is introducing some redundancy, but to me it seems a very, very good code-practice, one that my teachers insisted on righteously in my opinion.
Not only is the performance penalty very little, more important : relying on the default is relying on the knowledge of each programmer ever to use a piece of code, on every datatype that comes with a default. (DateTime ?)
Seriously, I think this is very strange : the very program that should protect you from making all too obvious mistakes, is suggesting here to make one, only for some increased performance? (we're talking about INITIALIZATION CODE here, only use one time!! Programmers who care that much, can ommit of course the initialization, (and should probably use C or assembler :-))
Is FXCop making an obvious mistake here, or is there more to it?
2 Updates :
This is not just my opinion, but what I have been teached at university (belgium), not that I liketo use an argumentum ad verecundiam but just to show that it isn't just my opinion, and concerning that :
My apologies, i just found this one : http://stackoverflow.com/questions/636102/should-i-always-ever-never-initialize-object-fields-to-default-values