Why do you believe it’s a false-positive/false-negative? When using dependency injection in a Razor template, S3353 is raising a violation, although such injections can’t have a const modifier.
Are you using…? The SonarAnalyzer.CSharp NuGet package, v10.6.0.109712.
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
Thank you for the reproducer, I am able to reproduce the issue now.
However, I can only reproduce this issue inside Visual Studio.
Is this case for you as well?
Do you see the issue during the build (e.g.: the issue appears in SonarQube or SonarCloud)?
I also tried to reproduce the issue in Rider and there is no issue there as well.
I suspect the issue might come from how Visual Studio generate razor pages for in-IDE analysis.