FixAll in project/solution does not fix all violations
Version Used: VS 2017.5 Preview 4
Steps to Reproduce:
- Sync to Roslyn master bdd16d9d21a3dc59c83ef73980aa574854b32c53
- Use latest version of https://dotnet.myget.org/feed/roslyn-analyzers/package/nuget/Microsoft.Net.RoslynDiagnostics by updating
MicrosoftNetRoslynDiagnosticsVersionat https://github.com/dotnet/roslyn/blob/master/build/Targets/Packages.props#L54 - Build to generate a bunch of
RS1016diagnostics. - Try to FixAll C# diagnostics using the IDE code fix.
Expected Behavior: All RS1016 diagnostics in C# projects are fixed.
Actual Behavior: Few RS1016 diagnostics don't get fixed. These unfixed diagnostics keep changing with every attempt, so I am presuming this is some race condition.
What is: RS1016
And what BatchFixer does it use?
I ask because the stock batch fixer has some major issues around text diffing and application of text changes. Specifically:
-
The standard source text diffing code tries to use a smart tree diff algorithm. However, many types of text changs can throw this algorithm waaaaaaay off, causing it to report thousands of changes, when sometimes it's just a single small edit that happened.
-
The fix all merging algorithm cannot handle overlapping edits properly (even if the overlapping part had the same text contents), causing it to bail out on changes a lot of the time.
Note that these are not race conditions. And, since we order the application of the fixes, should result in deterministic problems.
Depending on what changes you are making, it may be better to not use the standard batch fixer. That said, fixing the standard batch fixer would also be good. :)
RS1016
Sorry, I should have been more clear. See https://github.com/dotnet/roslyn/issues/23528#issue-278637845 for example.
And what BatchFixer does it use?
It uses the well known batch fixer in Roslyn. See https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/Core/FixAnalyzers/FixerWithFixAllAnalyzer.Fixer.cs#L25. It is a very trivial fixer, so I would have assumed FixAll should just work.
By the way, I closed and re-opened Roslyn.sln and now am unable to repro it after multiple attempts. Wondering if the original repro was something to do with project load state for some projects.
Like Manish mentions, this might be do to some project load state issue, but it might be worth having someone else try the repro before closing.
I was not able to repro this in the latest 15.7 build.