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

TreatWarningsAsErrors doesn't work on diagnostics configured via category #53742

Closed
jnm2 opened this issue May 28, 2021 · 2 comments
Closed

TreatWarningsAsErrors doesn't work on diagnostics configured via category #53742

jnm2 opened this issue May 28, 2021 · 2 comments
Assignees
Milestone

Comments

@jnm2
Copy link
Contributor

jnm2 commented May 28, 2021

Version Used: 16.10.0

Diagnostics configured via category or for all analyzers remain as warnings even when TreatWarningsAsErrors is true. They should instead be shown as errors in the error list and during command-line builds just like they do when each diagnostic is individually configured by ID to be a warning.

We don't want to configure these as errors because we don't want them to show that way in the IDE or block inner loop building/testing. We don't want to configure each diagnostic individually as a warning because that's a lot of lines. But we also want TreatWarningsAsErrors to turn these into errors during CI builds to prevent clutter from building up in the error list.

class C
{
    void M() { }
}
root = true

[*.cs]
dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning

# This doesn't work either
dotnet_analyzer_diagnostic.category.severity = warning

# Uncomment to see the warning start showing as an error in the Error List and in command line builds
# dotnet_diagnostic.IDE0051.severity = warning
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

</Project>
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels May 28, 2021
@jinujoseph jinujoseph added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 1, 2021
@jinujoseph jinujoseph added this to the 17.0 milestone Jun 1, 2021
@jinujoseph jinujoseph modified the milestones: 17.0, 17.1 Dec 10, 2021
@mavasani
Copy link
Contributor

Duplicate of #55541

@mavasani mavasani marked this as a duplicate of #55541 Dec 22, 2021
@mavasani
Copy link
Contributor

#58460 has been created to fix the underlying issue.

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

3 participants