Rider cannot resolve symbols in cshtml files ... until you type ?

I'm using Rider 2022.3.1 on Windows 11 on a .NET 4.8 Framework application. The solution-wide analysis went crazy and showed me 2600 errors in 76 files - all cshtml files. It could not resolve the @raw or @Model objects. I turned off and then on the analysys. I stopped and restared Rider. I rebooted. Visual Studio with resharper does not see them as problems and F12 navigates proerly there - but in Rider is says "Cant find a declaration to go to".

Then I typed the space bar. All the errors in the file vanished. So - while I have a work-around - touching 76 files is a drag.

Image before a keystroke:

Image after a keystroke: (I typed a "z" this time)

0
11 comments

This issue happens to me a lot as well, and I have to open all cshtml files type a space then remove it.

It seems to happen when there's big refactorings that touches classes referenced by cshtml files.

A similar issue sometimes happens in normal cs files, when I see phantom errors "ambiguous reference" showing the same class name multiple times, until I type or save the file, then suddenly all these errors disappear, almost like the analysis model is getting confused and having multiple copies of intermediate assemblies loaded at once and getting confused not using the latest one.

0

Hello,

could you please check if this problem still exists in Rider latest EAP6 build? While I can't reproduce the exact behavior you're describing (especially the "typing a space to resolve the problem" part), I can see some unexpected Ambiguous Reference problems that went away with EAP6.

If it's still relevant with EAP6, would it be possible for you to provide a sample solution that produces this behavior?

0

It happens on any large solution with razor views. It seems to get triggered by external changes to files happening in the middle of solution wide analysis incomplete analysis still analysing while also modifying something in the project and installing or updating multiple packages in NuGet at the same time (such as upgrade all packages in solution action). It is a multithreading / cache corruption / data race issue. There is no specific solution that reproduces the problem.

When this corruption state has been established, solution wide analysis will show many errors in the solution and opening a cshtml file will show red errors or cs files will show ambiguous reference error with the same referenced class name written multiple times, and typing or saving the file, invalidates the corrupted cache for this files and makes the error disappear and the solution wide error counter decrements. However, you have to open and modify every single file. This error will not disappear from all files at once except by close/reopen rider (sometimes doesn't work) or invalidate cache and restart rider action.

0

Hello,

Unfortunately, we still can't reproduce the issue. A sample solution would be very helpful. Also could you please check if the problem is still relevant for the latest Rider EAP build?

Alternatively, a full bundle of Rider logs could help us advance the investigation. Reproduce the problem, then perform the "type any character to make the errors disappear" action, then click Help | Collect logs and provide the archive with logs.

0

Hello,

Since I am not able to intentionally make it appear by a definite series of steps (it just happens randomly while working), I will collect and send logs next time it happens. I am unfortunately not able to switch permanently to using the EAP to try to test the issue because I cannot take the productivity hit of dealing with new bugs introduced by the EAP, but if I reach a definite series of steps, I will retest them on the EAP.

0

Raif Atef Yes, I understand that it is not easy to reproduce on demand. Thank you for your efforts in this regard. If you would be able to reproduce the problem with some certain trace logs enabled, it would be even more helpful:

  1. Go to Help | Diagnostic Tools | Choose Trace Scenarios
  2. Enable Editors and RazorCaches
  3. Reproduce the issue
  4. Collect logs via Help | Collect logs

Thank you in advance.

0

I have a zip with the log files, where do you want it?

0

Please upload the archive using the JetBrains Upload service and share the upload ID here. Thanks!

0

Here you go, if you need anything else, please say so: 2024_02_10_28yDNrdJ9umpu5dJnBGzHm

0

Thank you! There are some errors related to loading referenced assemblies in the logs that occur during design time build. Could you also share your *.sln and *.csproj files, please? 

Also, does it help if you clear caches via File | Invalidate Caches → Invalidate and Restart?

0

Invalidate caches fixed it.

I've uploaded the sln and the csproj files anyway: Upload id: 2024_02_13_2Ak6GuQpJxn8MjGjeQUPBj (files: TriasMVC.sln and 6 more)

0

Please sign in to leave a comment.