-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Usage analysis ignores references in documentation comments #2773
Comments
The "unused using" diagnostic is emitted by the compiler. It looks like the compiler is not even looking at doc comments when it doesn't need to generate a xml doc file and so doesn't include that code in it's analysis. |
We have an option to "Diagnose" xml doc comments but not emit them, but that also triggers all the other warnings and errors, and so I don't think VS integration sets it. We might need some finer grained control over the compiler's handling of xml doc comments. I remember discussing this with @amcasey a LONG time ago, but I don't think we resolved anything. |
+1 |
Hitcount++ from internal bug 1167079 |
If removing the Currently this results in bouncing back and forth between ReSharper complaining that you should add the using for the XML documentation and Roslyn complaining that you should remove it. It's a bad user experience. If the only correct solution is truly to enable XML doc generation, then please stop suggesting removal of the using and start suggesting enabling XML documentation output. This may be a moonshot, but in an ideal world, I think I should be able to leave XML documentation output off and still have all the syntax checking as though it was on, minus the warning about publicly visible types missing comments. |
@svick are you able to test this on tunnelvisionlabs/dotnet-threading? |
FWIW in thinking about the tradeoffs, the workflow I generally use is to configure debug builds to be as fast as possible, so I leave XML comments off. I rely on a release build, with all diagnostics, including static code analysis and XML comments, to be run often enough to catch deeper problems in a timely fashion. It's OK for the diagnostic build to be slower. However, it's not OK when I see that the usings in a C# file have gotten jumbled and so press Ctrl+R, Ctrl+G (Remove and Sort Warnings), to subtly introduce warnings or errors into the next diagnostic build. |
@dotnet/roslyn-ide @dotnet/roslyn-analysis @Pilchie @DustinCampbell I'm working on this issue now. My proposal is that the compiler will not produce any "unused using" diagnostics when the syntax trees are parsed with Are you OK with this? |
@gafter That seems a worse experience, in my mind. |
Also silently process doc comments when parsing them so we can report unused usings. Fixes dotnet#2773
I think the same way as @jcouv. |
Because we get a different syntax tree, and that is a compat break for an unknown number of clients. Are you suggesting that we |
I am +1 on @gafter's proposal as it retains the existing API and parse semantics for all documentation comment modes, does not increase the command line build time (however negligible) and improves the user experience for IDE scenario. API and parse semantics are very explicit on the DocumentationMode enum:
|
Fixed in #26425 |
Hurray! Finally! Thanks @gafter! |
Migrated from CodePlex
Consider the following class.
The behavior of Organize Usings varies by whether or not the current project is configured to generate an XML documentation file with the output.
using
declarations in the file shown above.At least for the purpose of analyzing
using
declarations, the behavior of Roslyn should not depend on whether or not the project is currently configured to produce an XML documentation file during the build.The text was updated successfully, but these errors were encountered: