Repository navigation
Test turning on analyzer VSTHRD103 in runtime - #48540
carlossanlop wants to merge 5 commits into
Conversation
|
Tagging subscribers to this area: @safern, @ViktorHofer Issue DetailsDo not merge. The objective of this draft PR is to show the output of turning on the existing VSTHRD103 analyzer in the dotnet/runtime repo, as requested in this comment. The analyzer was reviewed in the API Proposal meeting, and we determined that we want to see how noisy it would be in our repo, so we can decide what severity to assign to it once we move the code to the dotnet/roslyn-analyzers repo. In my local machine, it proved to be very noisy: Result: 259 Errors
|
|
Have you spot checked the violations? Are these false positives or are they potential opportunities for improvement in the runtime repo? |
| @@ -1,4 +1,7 @@ | |||
| <RuleSet Name="Microsoft.Analyzers.ManagedCodeAnalysis" Description="Microsoft.Analyzers.ManagedCodeAnalysis" ToolsVersion="14.0"> | |||
| <Rules AnalyzerId="Microsoft.VisualStudio.Threading.Analyzers" RuleNamespace="Microsoft.VisualStudio.Threading.Analyzers"> | |||
| <Rule Id="VSTHRD103" Action="None" /> | |||
There was a problem hiding this comment.
This isn't turning on VSTHRD103... it's using the default levels for all the rules in this library but explicitly turning off VSTHRD103. So all the results you posted are for all the other rules and not VSTHRD103.
There was a problem hiding this comment.
Oops, I got it backwards. Thanks for noticing.
All these errors are from CoreLib. It looks like the build just failed early and nothing in libraries got built. If you suppress these errors, I expect there will be many thousands more of these errors in the rest of libraries. Are any of these errors actual bugs, or are all of them just noise? |
|
My bad, Stephen pointed out that I didn't turn them on correctly. I disabled all the other VS analyzers and turned on VSTHRD103 as warning. Built again locally and here is the output for clr: Result: 10 errorsI have to fix the CLR ones so I can get Libraries results. |
|
You should be able to change the build in your PR to use |
|
Thanks. I'm building with that argument now. I noticed the fixer does not work, it crashes. Something to keep in mind when porting it to roslyn-analyzers. I also noticed there are cases that we will probably have to ignore, like those from Future.cs or TaskExtensions.cs. |
Most, if not all, of the warnings across the whole repo will be false positives / noise. |
|
I submitted some extra commits where I added comments to Result: 138 warnings |
| finally | ||
| { | ||
| sw.Dispose(); | ||
| sw.Dispose(); // await DisposeAsync |
There was a problem hiding this comment.
I don't understand what these comments are trying to say.
There was a problem hiding this comment.
Ah, I may have figured it out: What the suggested change is that would make the analyzer happier.
So I guess then my comment is "why are they comments instead of code changes?"
There was a problem hiding this comment.
What the suggested change is that would make the analyzer happier.
The analyzer warning is noise in most if not all of its comments. We should not be making these changes (or at least none of the ones I've audited thus far).
There was a problem hiding this comment.
@bartonjs you figured it out, yes.
My intention with this PR is to show what suggestions this analyzer would give us in runtime, and depending on how noisy it is (meaning how many would be false positives), decide what severity to approve for the API Proposal.
Which brings me back to the question:
- Do we need to go through API proposal again or can this be approved offline?
- Based on this level of noise, would it make sense to turn it on in runtime or should we disable it?
- Since it's being noisy, should the severity be info for the rest of the world, or can it be added to roslyn-analyzers as warning?
There was a problem hiding this comment.
Are they all were false positive? No any valid warnings? Is there any case we could tweak the analyzer to not warn for false positives?
There was a problem hiding this comment.
Do we need to go through API proposal again or can this be approved offline?
We don't need to go through API review.
Based on this level of noise, would it make sense to turn it on in runtime or should we disable it?
We should disable it.
Since it's being noisy, should the severity be info for the rest of the world, or can it be added to roslyn-analyzers as warning?
It should not be a warning. The noise we have with this in runtime is due to some common patterns that others use as well, e.g. a single method that has paths for sync and async, use of APIs that have an async alternative but where the developer knows the sync path is sufficient (e.g. FileStream.Dispose for a read-only FileStream), use of Task synchronous waiting methods on tasks known to already be complete, etc.
No any valid warnings?
It's possible there's a handful, but I doubt more than one or two that are legit, if that.
Is there any case we could tweak the analyzer to not warn for false positives?
It's possible, but it would need to be imbued with much more smarts.
We should definitely consider splitting functionality into multiple pieces. For example, I don't believe the warnings that fire for Task.Result/Wait/etc. should be part of this same diagnostic ID.
There was a problem hiding this comment.
Thanks, @stephentoub !
We don't need to go through API review.
@terrajobst can you please do the honors and mark the proposal as api-approved? (If there are no more concerns, of course).
We should disable it.
So I'll just close this PR. No changes for runtime.
It should not be a warning.
I assume this means using the "Info" severity for the rest of the world. Is this correct?
We should definitely consider splitting functionality into multiple pieces.
No problem, I can start working on that when moving it to roslyn-analyzers.
Do not merge.
The objective of this draft PR is to show the output of turning on the existing VSTHRD103 analyzer in the dotnet/runtime repo, as requested in this comment.
The analyzer was reviewed in the API Proposal meeting, and we determined that we want to see how noisy it would be in our repo, so we can decide what severity to assign to it once we move the code to the dotnet/roslyn-analyzers repo.
In my local machine, it proved to be very noisy:
Result: 259 Errors