Sonar is excluding my custom generated files, but I want to analyze them too

Versions used
SonarQube 8.9.1, MSBuild scanner

Error observed
I have a C# project, that contain a lot of .cs files that start with the line “// Generated by …”, and seems like Sonar is not picking up these files. But I still want to analyze them, without removing the "// Generated by … " line.
The logs are not showing any reasons why these files are excluded from the analysis.

I tried to set the following exclusions/inclusions, but it doesn’t help:

# Additional properties that will be passed to the scanner, 
# Put one key=value per line, example:
sonar.inclusions=**/*.cs,**/*.html
sonar.exclusions=**/Migrations/**
sonar.scm.exclusions.disabled=true

Logs

INFO: Indexing files of module ...
INFO:   Base dir: ...
INFO:   Source paths: ...
INFO:   Included sources: **/*.cs, **/*.html
INFO:   Excluded sources: **/Migrations/**
INFO: Indexing files of module ...
INFO:   Base dir: ...
INFO:   Included sources: **/*.cs, **/*.html
INFO:   Excluded sources: **/Migrations/**
INFO: 114 files indexed
INFO: 90 files ignored because of inclusion/exclusion patterns

Managed to fix the issue by passing
“sonar.cs.analyzeGeneratedCode=true”

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.