Open DoctorKrolic opened 2 years ago
This should have been fixed with https://github.com/dotnet/roslyn/pull/60081, will have to investigate
@dibarbet are there any known issues with pull diagnostics in 17.3 P2? I can repro this, but the EnC version stuff I added seems to still be working okay, from a quick look.
@dibarbet are there any known issues with pull diagnostics in 17.3 P2? I can repro this, but the EnC version stuff I added seems to still be working okay, from a quick look.
There have been some platform issues, but I don't remember one like this. Might need to try on p3
Nope, found the issue I think. When ending the debug session, documentsToReanalyze
is coming back as empty. Any ideas or recent changes you can think of @tmat, while I keep trying to debug?
Okay, we're tracking the document properly in the edit session, but when ending the session, its not the same session, as there is a BreakStateChanged call before that, so we actually restart the edit session just before we end it. Don't know if thats new?
When restarting though, we do seem to the do the right thing and bump version numbers etc. but the diagnostics don't get cleared. Not sure what is going on
Okay so when we get the break state changed, we know there is a document to reanalyze, but the reanalysis does nothing, because the document ID is not in the project that the work coordinator is running on. When we get the end session, there aren't any documents to analyze, because we've cleared them after the break state change.
I'm guessing this is a design time document issue of some kind, because we're asking the solution crawler to analyze Pages_Counter_razor.g.cs
but the project has Counter.razor.g.cs
in it
@davidwengier Thanks for the investigation. Does this repro when using pull diagnostics?
Yes, if I turn on the pull diagnostics flag in Tools, Options, it repros in a normal C# file too
I think there might be two issues here.. I can fix the issue in normal C# files with pull diagnostics turned on (fix in https://github.com/dotnet/roslyn/pull/62270) but the issue remains in Razor if pull diagnostics is turned off. I thought pull diagnostics was always on for Razor?
Fixed in #62270
@davidwengier I recently faced this issue again in 17.3. I then checked it in 17.4 Preview 1 and it is still there! I don't see any reason to publish another gif, because I did the same steps as in issue description and got absolutelly the same results. Can you please reopen this issue (it was closed by you, so I cannot reopen it myself) and reinvestigate it. I am open to provide any additional data if required.
Yep, I can repro this too. Thanks
Looks like my code is still working fine, and the Roslyn LSP handlers seem to be doing the right thing too. Will have to keep digging.
Current working theory is that with the solution crawler disabled for pull diagnostics, EnCs call to Reanalyze in order to clear rude edits is essentially no-oping, so whilst the version incrementing code I wrote is working, and we're sending back a new diagnostics response, that response still contains the old diagnostic because the document hasn't changed.
err.. I think it gets worse.. I'm not getting any rude edits in 32904.27.main which makes this very hard to debug. For a C# console app I get the errors, but they're all on line 1. For Razor I get nothing, but that probably makes sense if they're all on line 1, since we can't map that location.
...and now I can't repro this issue, or the rude edit issue above, under the debugger.. so I'm guessing there is a race somewhere.
@mavasani @tmat any pro tips for what to look for here? or even how to debug it?
The story, as far as I can tell, goes like this:
Seemingly at any point in the above we might get a pull diagnostics request, and it seems that when that happens, even if we've bumped the version in EditAndContinueDiagnosticUpdateSource, sometimes the rude edit still comes back from the diagnosticSource.GetDiagnosticsAsync
call.
It seems to me like the Reanalyze call is not blocking, and since the document content didn't change, perhaps that call is just returning cached data. I haven't been able to debug through to verify this, because debugging changes the timing of everything so much that either the problem doesn't repro, or diagnostics is so delayed I can't trust anything anyway. Unfortunately the timing also means its hard for me to confirm whether any of the fixes actually work. I suspect they don't, and what we need is a way to invalidate the diagnostics cache, rather than (or as well as) calling Reanalyze, but I have no idea where that would go.
Thoughts?
+ @CyrusNajmabadi
I feel like we should declare fixing this lost cause and wait until we can fully switch to pull diagnostics.
Is there some plan for how pull diagnostics will save us all? Because this is all reproing now with pull diagnostics on...
The current implementation is not using pull diagnostics directly. It's going thru the legacy diagnostic analyzer code paths.
Version used: VS 2022 v17.3 Preview 2
To reproduce:
Expected behavior: The error is gone after I stop debugging
Actual behavior: The error is gone only if I reopen the document
Demo:![devenv_N5smyMEIYc](https://user-images.githubusercontent.com/70431552/175790061-d5028dd0-bec8-427a-89c7-79ad7e03c780.gif)