Visual Studio 2010 code analysis warning CA1704 for class named MultiString

2.4k views Asked by At

I'm having troubles with the code analysis tool in Visual Studio 2010; I have a class used to manipulate multi-strings, therfore I named my class MultiString. When I run the code analysis tool I get the warning:

CA1704 : Microsoft.Naming : Correct the spelling of 'Multi' in type name 'MultiString'.

The same problem arises when is use the term multiString as paramter name or IsMultiApplicationCard as property name.

Thanks to the topic Code Analysis - CA1704: Correct the spelling of 'Ps' I found out that the term multi is unrecognized by default. Now I wonder why (I'm not a native speaker). Isn't multi a valid word? What word should I use instead? Or would you suggest to use Multiapplication and Multistring?

2

There are 2 answers

9
Paolo Falabella On BEST ANSWER

MultiString is parsed by Code Analysis into multi, string, which are then both checked against the dictionaries. Multi is a valid prefix for a word, but not a word by itself, i.e. multicolored is one word, so it should not be written multi colored. For this reason, the standard dictionary supplied by Microsoft in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml explicitly specifies multi as unrecognised; that in turn means that adding Multi to a custom dictionary is ineffective: Code Analysis will still reject it — but not explain why your dictionary entry is ineffective!

You best option seems to be to use Multistring (as you have noted yourself); second best would be to suppress CA1704 for this particular case; an administrator could presumably edit the standard dictionary, but that would need repeating after any updates, and seems a pretty dirty trick.

3
Nicholas Carey On

See http://msdn.microsoft.com/en-us/library/bb264492.aspx?ppud=4 for details on how to fix this "violation". 'Multi' is not in the microsoft dictionary. You can change it to, say, 'Multiple'...or you can add 'Multi' to a custom dictionary.