Codeman
Codeman

Reputation: 12375

How do I globally exclude an error for a certain message with the VS2012 code analysis tool?

I'm currently getting the following messages from the VS2012 code analysis tool:

CA1709 Identifiers should be cased correctly In member 'Action.ExecuteAction(string, string)', correct the casing of 'ID' in parameter name 'merchantID' by changing it to 'Id'. 'Id' is an abbreviation and therefore is not subject to acronym casing guidelines.

I have this defined in my GlobalSuppressions.cs file:

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
    "Microsoft.Naming", 
    "CA1709:IdentifiersShouldBeCasedCorrectly", 
    MessageId = "ID", 
    Scope = "Global")]

How can I define a rule that says "ignore this specific spelling (I want ID, not Id) in all files"?

EDIT: Mike's solution worked, this is what I ended up with:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
    <Acronyms>
        <CasingExceptions>
            <Acronym>ID</Acronym>
        </CasingExceptions>
    </Acronyms>
</Dictionary>

Upvotes: 4

Views: 944

Answers (1)

Mike Perrenoud
Mike Perrenoud

Reputation: 67918

What you're going to want to do, I believe, is add an acronym for ID to a custom dictionary and then you'll be able to drop the global suppression. Follow these instructions to do so.

But, in short, here is a snippet pulled from that document that should be what yours looks like a bit ...

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

... however, if it's not an acronym it's one of those categories.

Upvotes: 3

Related Questions