relatively_random
relatively_random

Reputation: 5186

How to properly add acronyms to CustomDictionary.xml

One of my classes has a public property named Ttl. This is supposed to follow the CA1709 rules:

By convention, two-letter acronyms use all uppercase letters, and acronyms of three or more characters use Pascal casing. The following examples use this naming convention: 'DB', 'CR', 'Cpa', and 'Ecma'. The following examples violate the convention: 'Io', 'XML', and 'DoD', and for nonparameter names, 'xp' and 'cpl'.

Now, code analysis complains about my property, telling me it violates CA1704 (bad spelling).

I tried adding it to my CustomDictionary.xml like this:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CodeAnalysisDictionary.xsd">

  <!-- Some unimportant elements are here in the real file -->

  <Acronyms>
    <CasingExceptions>
      <Acronym>Ttl</Acronym>    <!--Time To Live-->
    </CasingExceptions>
  </Acronyms>

</Dictionary>

I tried putting lower, upper and camel case into the dictionary, but none of them will remove the spelling complaint. Is there a way to add this acronym to the XML or do I just have to suppress the message for my properly named property?

Upvotes: 1

Views: 393

Answers (1)

nvoigt
nvoigt

Reputation: 77374

You added "Ttl" as a casing exception. In fact it's not. It's three letters in Pascal case.

What you did not do is add "Ttl" as a word.

<Words>
     <Recognized>
        <Word>Ttl</Word>

Make sure you need it at all. Most .NET languages have "no abbreviations" as a good naming convention.

Upvotes: 1

Related Questions