Search code examples
c#.netcode-analysisfxcop

Code Analysis Microsoft.Naming warnings on the abbreviation "ID"


I have been using ID (capital case) in all my property names and sql column names. Now i have started to correct all code analysis warnings to enforce new coding guidelines on the team.

Is there a way to add ID to a dictionary where it wont generate warnings (such as CA1709)?

Example -

Warning 4   CA1709 : Microsoft.Naming : Correct the casing of 'ID' in member name 'City.CityID' by changing it to 'Id'.
'Id' is an abbreviation and therefore is not subject to acronym casing guideline.

Solution

  • I ended up adding this in a custom dictionary - and it worked. Thanks Alastair Pitts

    <Dictionary>
      <Acronyms>
        <CasingExceptions>
          <Acronym>ID</Acronym>   <!-- Identifier -->
        </CasingExceptions>
      </Acronyms>
    </Dictionary>
    

    And it also helps me add other spellings which it complains about - like facebook, twitter etc.