4

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?

James Wierzba
  • 16,176
  • 14
  • 79
  • 120
  • Have you tried this answer https://stackoverflow.com/questions/3287656/how-to-suppress-a-stylecop-warning? – Vlad Stryapko Jul 05 '17 at 17:09
  • It is a different stylecop error, I want to know how to suppress this specific message – James Wierzba Jul 05 '17 at 17:11
  • You'll have to substitute the values from the answer with your own. I think the first parameter would be something like CSharp.Documentation or Microsoft,StyleCop.CSharp.Documentation. The second one would be SA1650:ElementDocumentationMustBeSpelledCorrectly – Vlad Stryapko Jul 05 '17 at 17:15
  • Just found the values, already put as answer – James Wierzba Jul 05 '17 at 17:16

2 Answers2

4

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
{
    // ...
}
granadaCoder
  • 26,328
  • 10
  • 113
  • 146
James Wierzba
  • 16,176
  • 14
  • 79
  • 120
2

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.

Philip Smith
  • 2,741
  • 25
  • 32
  • Your answer points to the document for FxCop. But, the issue here is a StyleCop one. Below comment from StyleCop documentation helps: `The CustomDictionary.xml file should be placed in the same folder as the StyleCop.dll and the Rules. That folder (and all subfolders) are checked for the dictionary files. StyleCop loads CustomDictionary.xml, CustomDictionary.en-GB.xml and then CustomDictionary.en.xml (where en-GB is the culture specified in the Settings.StyleCop file).` https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1650.md – RinoTom Dec 03 '18 at 13:23
  • @RinoTom The Moving Finger writes; and, having writ, Moves on... or as the French say "The more things change, the more they stay the same" – Philip Smith Mar 12 '19 at 14:55