James Wierzba
James Wierzba

Reputation: 17548

How to suppress stylecop error SA1650 (incorrectly spelled words)

I have a documentation header on a class, that has words that are not spelled correctly according to stylecop. They are code specific and need to be there, though.

Error SA1650 : CSharp.Documentation : The documentation text within the summary tag contains incorrectly spelled words: ...

I wish to suppress the error. How can I do this?

Upvotes: 4

Views: 7517

Answers (2)

James Wierzba
James Wierzba

Reputation: 17548

The solution that worked for me is to add [SuppressMessage(...)] attribute with the following parameters:

// using System.Diagnostics.CodeAnalysis;

/// <summary>
/// ... documentation with misspelled words ...
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed.")]
public class Program
{
    // ...
}

Upvotes: 5

Philip Smith
Philip Smith

Reputation: 2801

Using SuppressMessage to suppress warnings on words that are domain specific is a solution. However you need to add the attribute to all methods that contain those words.

It is IMHO better to implement a custom dictionary so that all instances of those words are ignored by the analysers and never generate warnings.

https://msdn.microsoft.com/en-us/library/bb514188.aspx describes the process of adding a custom dictionary - see the end of the article and pay particular attention to the build action. The article also describes the structure of the XML and what to do to resolve specific warnings.

Upvotes: 2

Related Questions