Start FreeLog in
SonarCloud | Advanced setup | Languages | C#

C#

On this page

Language-specific properties

Discover and update the C#-specific properties in the project Administration > General Settings > Languages > C#.

Analyze generated code

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.

Scanner compatibility

To analyze C# code, you need to use the SonarScanner for .NET version 4.x or newer.

Exclusions

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 Analysis Scope page.

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


Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License