CA1704 - Microsoft seems to be blocking the word 'Multi'?
Asked Answered
K

3

13
public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly

When I run Code Analysis, I get an error because the Microsoft does not recognize the word 'Multi' (go figure they use it in IMultiValueConverter). So, what I did to correct this was to add a CodeAnalysisDictionary.xml file and followed the steps supplied here. However, it doesn't seem to solve the situation, I still get a Code Analysis warning message.

To ensure that this isn't a bug with the recognized words section, I added another class and another exception.

public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly
public class MutiiSomething { } //NO WARNING

<Dictionary>
  <Words>
    <Recognized>
      <Word>Multi</Word> <-- This seems to not do anything... -->
      <Word>Mutii</Word> <-- This actually does something... -->
    </Recognized>
  </Words>
</Dictionary>

An alternative to fixing it is to use SuppressMessage, though that isn't a well fit solution if I plan on using this word all over the place.

[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
public class MultiSomething { } //NO WARNING (Suppressed)

Did Microsoft actually block 'Multi' from being added to the recognized words?

Kymry answered 21/10, 2011 at 19:47 Comment(0)
J
14

You can refer to this feedback ticket. This is apparently by design.

The behavior you are seeing is because Code Analysis ships with a pre-defined custom dictionary that always overrides any other custom dictionaries when there is a conflict. In this case “multi” is listed as an <unrecognized> word in the default FXCop dictionary.

To fix this issue, open the default dictionary %VS Install Directory%\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml and comment out or remove the “multi” entry from the <unrecognized> words section; "multi" will no longer be flagged as a spelling error in Code Analysis.

Jacklin answered 21/10, 2011 at 19:51 Comment(3)
Sadly the ticket is listed as "Won't Fix" ... apparently it's not "important enough" even though it's a 2 second fix.Kymry
Even if they wanted to fix it, it's a breaking change, since many people may be currently relying on the fact that "multi" is unrecognized by default.Algie
I entered this as a UserVoice request - vote!! visualstudio.uservoice.com/forums/121579-visual-studio/…Algie
G
6

try adding this to your customdictionary

<Deprecated>
  <Term PreferredAlternate="Multi">multi</Term>
</Deprecated>
Goddamned answered 25/8, 2017 at 16:15 Comment(1)
Wow, this actually worked. Thank you! I wonder if the reason this works is because of a bug in how FxCop considers words, instead of by-design. (I'm using Visual Studio 2017 with C# 7.2, otherwise stock code analysis options)Badtempered
R
0

You can add an XML File with Word Acronyms etc...

Add your xml file and set Build Action = CodeAnalysisDictionary

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
  <Words>
    <Unrecognized>
      <Word></Word>
    </Unrecognized>
    <Recognized>
      <Word>Multi</Word>
    </Recognized>
    <Deprecated>
      <Term PreferredAlternate=""></Term>
    </Deprecated>
    <Compound>
      <Term CompoundAlternate=""></Term>
    </Compound>
    <DiscreteExceptions>
      <Term>PostDate</Term>
    </DiscreteExceptions>
  </Words>
  <Acronyms>
    <CasingExceptions>
      <Acronym></Acronym> 
    </CasingExceptions>
  </Acronyms>
</Dictionary>
Rabid answered 25/6, 2019 at 20:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.