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: sub-diagnostics for finer granularity severity configuration #27712

Open
sharwell opened this issue Jun 11, 2018 · 6 comments
Open
Labels
Area-Analyzers Concept-API This issue involves adding, removing, clarification, or modification of an API. Need Design Review The end user experience design needs to be reviewed and approved.
Milestone

Comments

@sharwell
Copy link
Member

sharwell commented Jun 11, 2018

Currently, the upcoming .editorconfig support in the compiler allows diagnostic severities to be configured as follows:

dotnet_diagnostic.xUnit2017.severity = warning

This behavior is not flexible enough to support cases where the same diagnostic ID needs to be reported with different severity values depending on context. One example where this appears today is naming convention rules.

I propose extending the diagnostic ID form from the current [Identifier] to also allow [Identifier]+[SubIdentifier]. If a diagnostic is reported using the optional sub-identifier, the severity will be used for the sub-identifier case, if available. In all cases, the UI and compiler output would omit the sub-identifier from reporting.

# Set the default severity for naming style violations
dotnet_diagnostic.IDE1006.severity = error

# Override the default severity for naming styles from the 'LocalsAreCamelCase' rule
dotnet_diagnostic.IDE1006+LocalsAreCamelCase.severity = suggestion

The SuppressMessageAttribute.MessageId property could be used for a targeted suppression of a specific sub-identifier.

@CyrusNajmabadi
Copy link
Member

Dumb question: why + instead of ust .?

@mavasani
Copy link
Contributor

If we implement this, it should use a '-' as a separator, similar to category based configuration: dotnet_analyzer_diagnostic.category-<DiagnosticCategory>.severity = <severity>. See https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019#set-rule-severity-of-multiple-analyzer-rules-at-once-in-an-editorconfig-file

@jez9999
Copy link

jez9999 commented May 28, 2020

So how can I upvote this?

@CyrusNajmabadi
Copy link
Member

Use the thumbs-up at the top:

image

@Evangelink
Copy link
Member

I don't think I would be very valuable but @sharwell I'd be happy to help (if you need some).

@sharwell sharwell added Concept-API This issue involves adding, removing, clarification, or modification of an API. Need Design Review The end user experience design needs to be reviewed and approved. labels Jul 13, 2020
@sharwell sharwell moved this to Need Proposal in IDE: Design review Aug 22, 2023
@mavasani
Copy link
Contributor

mavasani commented Nov 6, 2023

I believe this can be trivially implemented once #69843 goes in. We also don't need dotnet_diagnostic syntax for configuring such sub-severities. We can support any desired syntax that blends well with existing naming rule configuration syntax and doesn't need to use opaque IDs such as IDE1006 in the configuration entry: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules#general-syntax. For example, dotnet_naming_rule.locals_are_camel_case.severity = suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers Concept-API This issue involves adding, removing, clarification, or modification of an API. Need Design Review The end user experience design needs to be reviewed and approved.
Projects
Status: Complete
Development

No branches or pull requests

7 participants