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

EnforceCodeStyleInBuild does not detect unused usings without GenerateDocumentationFile #53720

Closed
jnm2 opened this issue May 27, 2021 · 3 comments
Assignees
Labels
Area-IDE Bug Resolution-Duplicate The described behavior is tracked in another issue
Milestone

Comments

@jnm2
Copy link
Contributor

jnm2 commented May 27, 2021

Version Used: dotnet 5.0.300

No errors or warnings are shown when running dotnet build like they are in the error list (or other variations on this, like having no TreatWarningsAsErrors or having editorconfig setting severity to error):

using System;
root = true

[*.cs]

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = warning
<Project Sdk="Microsoft.NET.Sdk">

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

</Project>

Adding <GenerateDocumentationFile>true</GenerateDocumentationFile> fixes the problem, but I don't think I should have to add this. The point of EnforceCodeStyleInBuild is so that CI fails on things we miss that would bring clutter to the error list. If IDE0005 is showing in the error list without GenerateDocumentationFile, it should fail CI without GenerateDocumentationFile.

Besides that, it has awful discoverability to have to set GenerateDocumentationFile to get EnforceCodeStyleInBuild to work with IDE0005. GenerateDocumentationFile was a lucky guess based on a comment I saw on Twitter last month, and I'd already tried this four or five times since EnforceCodeStyleInBuild shipped and I completely failed and gave up each time.

/cc @jmarolf

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 27, 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
@mavasani
Copy link
Contributor

mavasani commented Jun 1, 2021

This is a duplicate of #41640

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 1, 2021

Should I close or does that mess up the milestone?

@mavasani
Copy link
Contributor

mavasani commented Jun 1, 2021

I think it is good to close out, let me do so.

@mavasani mavasani closed this as completed Jun 1, 2021
@mavasani mavasani added the Resolution-Duplicate The described behavior is tracked in another issue label Jun 1, 2021
mavasani added a commit to mavasani/roslyn that referenced this issue Jan 13, 2022
…ngs) on build

Due to dotnet#41640, enabling IDE0005 on build requires users to enable generation of XML documentation comments. Even though this is documented with a note on IDE0005's [doc page](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005), we have had numerous reports of users not figuring this out and spending lot of cycles fighting with this, especially given other IDE diagnostics work just fine on build. We have had many user reports of the same: dotnet#58103, dotnet#53720, dotnet#57539, OpenRA/OpenRA#19747 and numerous other offline queries.

This change enhances the IDE0005 analyzer to now detect the case when IDE0005 is being reported as a warning or an error in the IDE, but `GenerateDocumentationFile` is `false` for the project, which would mean IDE0005 wouldn't be reported on build. The analyzer reports a special helper diagnostic for this case, which recommends  the user to set this property to `true` in their project file to enable IDE0005 on build. This should reduce the pain for customers who try to enforce IDE0005 on build and get hit by this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

3 participants