0

Is there a way to make the code analysis spell-checker accept an acronym that contains a number?

I'm getting CA1704 and CA1709 warnings from code analysis in a C# application where I have identifiers with an acronym that contains a number. For example, "CheckAbc2deStatus". CA1704 wants to correct the spelling of Abc, while CA1709 wants "de" changed to "DE". I found Code analysis, Lost between CA1709 and CA1704 and have tried putting "Abc2de" in the code analysis dictionary as Words/Recognized/Word, Words/Compound/Term, and Acronyms/CasingExceptions/Acronym, but none of those entries will make the code analyzer happy. Other entries in the custom dictionary for "normal" acronyms work as expected.

Community
  • 1
  • 1
Arthur Ward
  • 597
  • 3
  • 20

1 Answers1

1

I got it to work with:

Code:

    public static bool CheckABC2DEStatus()
    {
        return true;
    }

And in the Code Analysis Dictionary:

  <Acronyms>
    <CasingExceptions>
      <Acronym>ABC</Acronym>
      <Acronym>DE</Acronym>
    </CasingExceptions>
  </Acronyms>

The number seems to be treated as a word break, so I had to put the two halves in seperately.

If CheckABC2DEStatus isn't your preferred method name, let me know and I'll try and adjust the dictionary entry accordingly.

NikolaiDante
  • 18,469
  • 14
  • 77
  • 117
  • It's not ideal, since it allows ABC and DE to occur as separate words. If I understand the C# naming guidelines correctly, acronyms shouldn't be capitalized. I took your suggestion and tried it using "Abc" and "de", but that doesn't work. I'll just roll with the all-caps approach you gave and file a report with Microsoft. – Arthur Ward Jan 15 '16 at 18:05
  • Casing exceptions are for things that are uppercase, recognised words for others. And yes I know MS break this themselves with the Mvc namespace :-) – NikolaiDante Jan 15 '16 at 19:57