Pregunta

We have CA1709 enabled in our Code Analysis rule set:

CA1709: Identifiers should be cased correctly

For the most case, it is a great rule to have in place, but sometimes it can be a real pain.

For example, we use the deCarta mapping API and have services such as DeCartaSuchAndSuch. This results in the following warning:

CA1709 : Correct the casing of 'De' in type name 'DeCartaSuchAndSuch' by changing it to 'DE'.

Now you can imagine how many times I have to surpress this exact warning.

Question: Is it possible to make exceptions for a specific warning? For example, I want this warning to be ignored for all cases of "DeCarta".

¿Fue útil?

Solución

For such cases create a custom dictionary of acceptable, recognized words. You can find the instructions here. For your particular case it could look like this:

<Dictionary>
     <Acronyms>
       <CasingExceptions>
          <Acronym>De</Acronym>
          ...
       </CasingExceptions>
       ...
    </Acronyms>
    ...
</Dictionary>

Otros consejos

Maybe this can help!

I have found this.

http://dansen.wordpress.com/2008/04/15/suppressing-code-analysis-rules/

it says something like:

When selecting the Project Supressions File option, the SuppressMessageAttribute is placed in the projects GlobalSuppressions.cs file.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage(
"Microsoft.Design",
"CA2210:AssembliesShouldHaveValidStrongNames")]

I think that maybe you can do the same with CA1709

I hope this helps ;)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top