roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

FixAll in project/solution does not fix all violations

Open mavasani opened this issue 8 years ago • 4 comments

Version Used: VS 2017.5 Preview 4

Steps to Reproduce:

  1. Sync to Roslyn master bdd16d9d21a3dc59c83ef73980aa574854b32c53
  2. Use latest version of https://dotnet.myget.org/feed/roslyn-analyzers/package/nuget/Microsoft.Net.RoslynDiagnostics by updating MicrosoftNetRoslynDiagnosticsVersion at https://github.com/dotnet/roslyn/blob/master/build/Targets/Packages.props#L54
  3. Build to generate a bunch of RS1016 diagnostics.
  4. 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.

mavasani avatar Dec 04 '17 16:12 mavasani

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:

  1. 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.

  2. 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. :)

CyrusNajmabadi avatar Dec 04 '17 21:12 CyrusNajmabadi

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.

mavasani avatar Dec 04 '17 21:12 mavasani

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.

dpoeschl avatar Dec 20 '17 04:12 dpoeschl

I was not able to repro this in the latest 15.7 build.

vsccarl avatar Mar 07 '18 22:03 vsccarl