简体   繁体   中英

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?

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
{
    // ...
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM