dotnet / dotnet/roslyn

Support limiting CS1591 to certain members

Open
#74,209 0 comments 1 reaction 1 assignee Assigned to @JoeRobich View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

### Brief description

I'd like to request a small enhancement to [CS1591 Missing XML comment for publicly visible type or member 'Type_or_Member'](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1591).

My team almost always adds XML comments for public classes and enums but rarely for public methods or properties. Therefore, I'd like a more fine-grained control over CS1591. Namely, it'd be great if there's something like `csharp_add_xml_comment_for_publicly_visible_type_or_member=class,enum`, which would trigger CS1591 for classes and enums but not for methods or properties. Is this feasible? (Maybe not if the `.editorconfig` value can only be a single value...)

### Languages applicable
C# only

### Code example that the analyzer should report
C# file:
```cs
namespace MyNamespace;

public enum MyEnum // flagged
{
One,
Two,
}

public class MyClass // flagged
{
public int MyProperty => 1; // not flagged

public void MyMethod() => throw new NotImplementedException(); // not flagged
}
```
`.editorconfig`:
```editorconfig
csharp_add_xml_comment_for_publicly_visible_type_or_member=class,enum:warning
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.