Exclude generated code from analysis in SonarLint

My project contains generated C# code (generated_code = true in editorconfig) that I would like SonarLint to ignore.
The SonarLint issue tracker states that sonar.exclusions are not synchronizable, that’s fine. I would just like any way for SonarLint to ignore my generated (.cs) code files that are in a specific folder.
So far this doesn’t seem to be possible which means I won’t be able to use the Sonarlint-visual studio plugin.
For what it’s worth I too have a paid account on sonarcloud.io.

Hi @MrSanchez - welcome to the community.

The Roslyn-based Sonar analyzers have their own mechanism for detecting generated code that pre-dates .editorconfig files, which is presumably why the generated_code setting isn’t having an effect.

The only workaround I can think of at this point is to renamed your generated files to end with an extension that the Sonar analyzers recognise as indicating generated code e.g. .g.cs.

2 Likes

Ah that does sound like a plausible explanation. I see.

While tedious, I’ll keep that workaround in mind.

Thanks!

This topic was automatically closed after 20 hours. New replies are no longer allowed.