Red error lines but still compiling
My project is a ASP.NET Core Web App.
- Targer Framework: net6.0.
- Language Version C# 10.0.
- Type: Blazor Server App.
- Rider 2023.1.2
I have over 100 errors marked in my project but the project compiles and runs despite this.
I've tried:
- Rebuilding, cleaning solution.
- Opening the solution after moving it to another folder.
- File > Invalidating Caches and restarting. Ticking all and no boxes with other options.
The first error occurs on my .razor page with an injected service:
@inject IPlaceHolderService PHS
Rider will suggest to reference it but the interfaces namespace is already referenced in the page with a @using statement properly. Most of the other lines of code that are errors are from methods in the interface and other Classes and variables referenced throughout the .razor page.
Attemping to import missing files/references results in the same usings being copied again which are already there not helping.
Please help.
Please sign in to leave a comment.
Hello,
Could you please share the affected solution with us? You can use JetBrains Upload Service to share the files privately.
Thank you in advance.
Hi Ivan,
The problem has been solved.
You may be interested to know that the problem was caused by placing a commented open curly bracket after a case: inside a switch statement.
Below will introduce red errors all over the .razor file but it will still compile (and other variations of adding the { on the line above). These errors may also interfere with intellisense. This was hard to work out what was going on as it was commented and therefore seemed fine.
Hello,
Unfortunately, it looks like you have faced a known issue: RIDER-95984 Code analysis failing in Razor component when C# comment in @code { } section has curly brace in it. We would appreciate it if you would upvote it in order to bring increased awareness to the issue. One can also click Watch to monitor the status.
The workaround is to avoid using curly braces in commented blocks in Razor files until this issue is fixed.