# C\#

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

Discover and update the C#-specific [analysis-parameters](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/analysis-parameters "mention") in: **Administration > General Settings > Languages > C#**.

### 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 from analysis.

The detection of generated code is based on 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.Common/Helpers/GeneratedCodeRecognizer.cs).

## 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-server/10.5/analyzing-source-code/scanners/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.

As an alternative, an `.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.

```css-79elbk
[Path/File.cs]
dotnet_diagnostic.Sxxx.severity = none
```

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

* [external-analyzer-reports](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/importing-external-issues/external-analyzer-reports "mention") (VSTest, NUnit, MSTest, xUnit)
* [external-analyzer-reports](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/importing-external-issues/external-analyzer-reports "mention") (See "Notes on external .NET issues")
* [dotnet-test-coverage](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/test-coverage/dotnet-test-coverage "mention") (Visual Studio Code Coverage, dotCover, OpenCover, Coverlet, Altcover)
* [sonarscanner-for-dotnet](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/scanners/sonarscanner-for-dotnet "mention")
* [sonarqube-extension-for-azure-devops](https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops "mention")
* [Analysis of product projects vs. test projects](https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects)
* [Troubleshooting guide for .NET code coverage import](https://community.sonarsource.com/t/37151)
* [Investigating the performance of .NET Analysis](https://community.sonarsource.com/t/47279)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/10.5/analyzing-source-code/languages/csharp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
