FxCop 1.35 RC1 - SuppressMessage for IdentifiersShouldBeSpelledCorrectly

Is it possible to suppress all violations for a given word using a single module-level SuppressMessage attribute

For example, if I use the unrecognized word "Foo" in several places in my code, e.g.:



public int AddFoo(Foo f)
{
...
}
public void RemoveFoo(Foo f)
{
...
}

I would like to suppress the IdentifiersShouldBeSpelledCorrectly violations for all instances of "Foo" with a single module-level SuppressMessage attribute. I tried the following but it didn't work:



[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Foo")]




Answer this question

FxCop 1.35 RC1 - SuppressMessage for IdentifiersShouldBeSpelledCorrectly

  • Vítor Ferreira

    JocularJoe wrote:

    I assume a future version of VSTS Code Analysis will include spelling/casing checks, and at that point it will be a mainstream requirement to be able to exclude project-specific terminology from spelling checks. I expect VSTS will do this using the SuppressMessageAttribute, as I don't see how else it would record the project-specific terms.

    Would it not be possible to agree some suitable semantics for the SuppressMessageAttribute with the VSTS team, and implement it now in standalone FxCop - e.g. something along the lines of [SuppressMessage(... Scope="*" ...)]

    Yes the next version of VSTS will include spelling (casing checks are already included) checks. We also will have a solution to be able to ignore project-specific words, how we will go about this hasn't been determined yet (we develop both FxCop and VSTS Code Analysis).

    Regards

    David



  • CodeWarrior1

    Now I have in-source suppressions, I was hoping to eliminate both the FxCop project file and the custom dictionary file.

    I assume a future version of VSTS Code Analysis will include spelling/casing checks, and at that point it will be a mainstream requirement to be able to exclude project-specific terminology from spelling checks. I expect VSTS will do this using the SuppressMessageAttribute, as I don't see how else it would record the project-specific terms.

    Would it not be possible to agree some suitable semantics for the SuppressMessageAttribute with the VSTS team, and implement it now in standalone FxCop - e.g. something along the lines of [SuppressMessage(... Scope="*" ...)]


  • Gabe J

    Joe,

    Unfortunately, using SuppressMessage like that will not work. However, you can add the unrecognized word to a CustomDictionary.xml that is placed in the same directory as the FxCop project. It has the following format:

    <Dictionary>
    <Words>
    <Recognized>
    <Word>
    Foo</Word>
    </Recognized>
    </Words>
    </Dictionary>

    FxCop will ignore any words located this this file.



  • FxCop 1.35 RC1 - SuppressMessage for IdentifiersShouldBeSpelledCorrectly