# Source: https://docs.sonarsource.com/sonarqube-community-build/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/8.9/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/9.8/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/9.9/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.0/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.1/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.2/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.3/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.4/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.6/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.7/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/10.8/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.2/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.3/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.5/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.4/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/2025.6/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/languages/csharp.md

# Source: https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/csharp.md

# C\#

### Supported versions <a href="#supported-versions" id="supported-versions"></a>

The level of support for a language is defined as follows:

* Fully supported: Analysis will complete. All the language features are understood and examined.
* Supported: Most language features are understood and examined but the version includes unsupported features. Analysis might break or provide incomplete results.

C#1 to C#14: Fully supported

### Supported frameworks and tools <a href="#supported-languages-and-tools" id="supported-languages-and-tools"></a>

ASP.NET MVC, ASP.NET Core MVC

### Language-specific properties <a href="#language-specific-properties" id="language-specific-properties"></a>

To discover and update the C#-specific properties, navigate in SonarQube Cloud to *Your Project* > **Administration** > **General Settings** > **Languages** > **C#**. See the [analysis-parameters](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/analysis-parameters "mention") page for more information about specific properties.

#### Analyze generated code <a href="#analyze-generated-code" id="analyze-generated-code"></a>

To analyze tool-generated code (e.g. WCF code generated by `SvcUtil.exe`, protobuf code generated by `protoc`, Swagger client code generated by `NSwag`) for a specific C# project, enable the "Analyze generated code" setting inside **Project > Administration > General Settings > C#**. By default, tool-generated code files are skipped during analysis.

The detection of generated code is based on the file name, special comments, and attributes. The currently recognized values are in [GeneratedCodeRecognizer.cs](https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/src/SonarAnalyzer.Core/Syntax/Utilities/GeneratedCodeRecognizer.cs).

{% hint style="info" %}
When a `Generated` comment is present in the file, SonarQube ignores the *entire* \*\* *file*, even if only parts of it were generated. It’s possible to enable or disable analysis of *files containing generated code* at the project level in *Your project* > **Administration** > **General Settings** > **Languages** > *Your language* > **Analyze generated code**.
{% endhint %}

### Scanner compatibility <a href="#scanner-compatibility" id="scanner-compatibility"></a>

To analyze C# code, you need to use the [sonarscanner-for-dotnet](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-dotnet "mention"), version 4.x or newer.

### Exclusions <a href="#exclusions" id="exclusions"></a>

Files to be excluded should be set in the project configuration. Excluded files are still going to be analyzed during the compilation and the results will be filtered according to the exclusion settings. Details about inclusions and exclusions can be found on the [setting-analysis-scope](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/project-analysis/setting-analysis-scope "mention") pages.

As an alternative, a `.editorconfig` file can be used to disable the analysis for a specific rule on a file or directory. This can solve performance problems on large files.

`[Path/File.cs]`\
`dotnet_diagnostic.Sxxx.severity = none`

### Related pages <a href="#related-pages" id="related-pages"></a>

* [Investigating the performance of .NET Analysis](https://community.sonarsource.com/t/the-sonarsource-guide-for-investigating-the-performance-of-net-analysis/47279)
* Importing external issues: [external-analyzer-reports](https://docs.sonarsource.com/sonarqube-cloud/enriching/external-analyzer-reports "mention") (NUnit, MSTest, xUnit)
* For excluding external Roslyn issues: [external-analyzer-reports](https://docs.sonarsource.com/sonarqube-cloud/enriching/external-analyzer-reports "mention"). See also [#notes-on-external-.net-c-or-vb.net-issues](https://docs.sonarsource.com/sonarqube-cloud/enriching/external-analyzer-reports#notes-on-external-.net-c-or-vb.net-issues "mention")
* [c-c-objective-c-test-coverage](https://docs.sonarsource.com/sonarqube-cloud/enriching/test-coverage/c-c-objective-c-test-coverage "mention") (Visual Studio Code Coverage, dotCover, OpenCover, Coverlet, Altcover, VSTest)
* The [sonarscanner-for-dotnet](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-dotnet "mention")
* The [sonarcloud-extension-for-azure-devops](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops "mention") for SonarQube Cloud
* [Specifying test projects](https://app.gitbook.com/s/yDv2XwTC1xoOKBYeCK45/analyzing-source-code/dotnet-environments/specify-test-project-analysis "mention") (the page is in the SonarQube Server docs, but also applies when setting up SonarQube Cloud .NET projects)
* [dotnet-test-coverage](https://docs.sonarsource.com/sonarqube-cloud/enriching/test-coverage/dotnet-test-coverage "mention")