SonarQube Analysis for .cshtml files

I am running a .net framework 4.7 with Umbraco 8. I got to know from Sonarqube docs that now cshtml files are supported for Analyzing.
I am trying to integrate Sonarqube with my project but when I run it then it does not provide any issues in my code, I have also commented code, and written unused variables into it but it does not give a single issue with that. Can you please look into this and provide any feedback points:

SonarQube Version: 10.4.1

I am writing sample code for the reference (e.g. Accounts.cshtml):

/* var BillingContacts = JsonHelper.request("BillingContactName");
         var PrimaryContacts = JsonHelper.request("PrimaryContactName"); */

var BillingContactID = JsonHelper.request("AccountName");
var PrimaryContactID = JsonHelper.request("TenantID");
var unusedVariable;

        string query = @"
            declare @Ids table ( id int )
            declare @AccountID int

                INSERT INTO [Accounts]

Hi @ayush8771

In SonarQube and SonarCloud, we support analysis of Razor files (.cshtml and .razor) with all our rules only for .NET Core and .NET projects.

For .NET Framework, only the cross site scripting (XSS) rule currently works on Razor templates, raising issues on .cshtml files.

As technical details:

  • in .NET Core and .NET projects, the Razor templates are compiled during the build and source generators are invoked to generate C# code for each Razor template during the build. We analyze the source-generated code and map the issues back to the Razor templates (.cshtml and .razor files).
  • .NET Framework does not compile Razor templates at build time and does not use source generators, and this is why there is this difference of behavior.

Hi @ayush8771,

As Andrei said, we currently do not support analyzing Razor syntax for .NET framework.
However, I have added the feature for consideration. Thank you for your input!


Thanks for your updates.

Thanks for the updates