Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Allow fine-grained control over when documentation is checked on interfaces #3100

Open
RobSiklos opened this issue Jan 6, 2020 · 6 comments

Comments

@RobSiklos
Copy link

Spawned from #2934 (comment)

Overview
This is a proposal to allow control over how much StyleCop cares about documentation on internal interfaces.

Background
According to the above issue, documentInterfaces=true takes precedence over documentInternalElements = false. This means that if you want StyleCop to check documentation on public interfaces, it will also check documentation on internal interfaces. There is currently no way to have StyleCop check documentation on public interfaces while ignoring internal interfaces.

Rationale
We have many external interfaces and each must have documentation that adheres to all the StyleCop rules. However, for internal interfaces (of which we also have many), we don't care if any of the documentation elements are missing.

Suggested Solution
I propose that the documentInterfaces item in stylecop.json be enhanced to support the following values:

  • "all" - (default value) Indicates that documentation on internal as well as public interfaces should be checked.
  • "external" - Indicates that documentation should only be checked on interfaces if they are externally visible.
  • "none" - Indicates that documentation should not be checked on interfaces (equivalent to "documentInterfaces": false in current behaviour).
  • true - For backward compatibility. Equivalent to "all"
  • false - For backward compatibility. Equivalent to "none"

Example:

    "documentationRules": {
      "documentInterfaces": "external",
      "documentExposedElements": true,
      "documentInternalElements": false
    }
@sharwell
Copy link
Member

sharwell commented Jan 6, 2020

I'm 👍 on this, with the one change that we use "exposed" instead of "external" for consistency.

@Ekkeir
Copy link

Ekkeir commented Oct 4, 2021

Is there a known state for this feature?
Mandatory documentation for public interfaces, but not external ones would be of great practical use.

@sharwell
Copy link
Member

Based on this method, I'm not sure a change is needed here.

public static bool NeedsComment(DocumentationSettings documentationSettings, SyntaxKind syntaxKind, SyntaxKind parentSyntaxKind, Accessibility declaredAccessibility, Accessibility effectiveAccessibility)

The following should be equivalent to the new external option presented above:

"documentationRules": {
  "documentInterfaces": false,
  "documentExposedElements": true
}

@bjornhellander
Copy link
Contributor

"documentationRules": {
  "documentInterfaces": false,
  "documentExposedElements": true
}

This would require documentation on all exposed types, not just interfaces.

@AraHaan
Copy link

AraHaan commented Feb 29, 2024

"documentationRules": {
  "documentInterfaces": false,
  "documentExposedElements": true
}

This would require documentation on all exposed types, not just interfaces.

if you don't want docs on other types that are public make them internal and use InternalsVisibleTo on the msbuild side itself then.

@sharwell
Copy link
Member

sharwell commented Mar 4, 2024

Thanks @bjornhellander missed that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants