.netvisual-studiocoding-stylecode-analysisstylecop

Disable StyleCop's SA1600 rule for internal interfaces


StyleCop.Analyzers: 1.1.118

My stylecop.json:

 {
      "$schema":
        "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
      "settings": {
        "documentationRules": {
          "companyName": "ShapeCrawler",
          "documentInternalElements": false
        }
      }
    }

Sample:

enter image description here

Is it possible to disable "SA1600: Elements should be documented" rule for internal interfaces?


Solution

  • By definition, internal interfaces are visible to all types within the assembly, and any assemblies that have a "friend" relationship with it via the InternalsVisibleTo attribute. It's generally a good idea to document public members of internal types (including interfaces) unless you have a truly compelling reason not to; at the very least, you'll benefit from IntelliSense documentation at the point of call.

    Having said that, if you're determined not to document them, wrap the type in the following:

    #pragma warning disable 1591
    [Your code here]
    #pragma warning enable 1591