SonarQube problem with C# Source Generators

Hello,

We have a problem with sonar scanner version “5.4.0”.

When we use libraries that use source generators (like https://github.com/mostmand/Cloneable) our build fails when we run the SonarQubePrepare task before the build in the azure pipeline, when we do not use the SonarQube task the build works fine.
It looks like SonarQube somehow blocks the code to be generated, because we get this error messages in the build:

  • Error CS0246: The type or namespace name ‘Cloneable’ could not be found (are you missing a using directive or an assembly reference?)

  • Error CS0246: The type or namespace name ‘Cloneable’ could not be found (are you missing a using directive or an assembly reference?)

  • Error CS0246: The type or namespace name ‘CloneableAttribute’ could not be found (are you missing a using directive or an assembly reference?)

  • Error CS0246: The type or namespace name ‘Cloneable’ could not be found (are you missing a using directive or an assembly reference?)

This problem is very similar to this post https://community.sonarsource.com/t/c-sonar-scanner-with-source-generators/54056

Thank you in advance!

PipeLine.txt (925 Bytes)
SonarQubePrepareLog.txt (1.8 KB)
FailingBuildLog.txt (396.0 KB)
WorkingBuildLog.txt (410.2 KB)

Hi,

Welcome to the community!

The current version of SonarScanner for .NET is 5.5.3. Could you try upgrading and see if there’s still a problem?

 
Thx,
Ann

Hi,

thanks for the response!
We used the SonarScanner for Azure DevOps where the newest version is 5.4.0, sorry for the misunderstanding.
I now tried to use the SonarScanner for .NET with the newest version but the problem still remains

BR,
Severin

Hi Severin,

Thanks for trying the other scanner. This is now officially beyond me, but it’s flagged for more expert attention. Hopefully they’ll be along soon.

 
Ann

Hello @Severin

I see you are using sonar.cs.roslyn.ignoreIssues=true which currently has a bug, and removes also the reference to the source generator you are using. See: The `GetAnalyzerSettings` task is removing existing code generators when `sonar.cs.roslyn.ignoreIssues` is set to true · Issue #1211 · SonarSource/sonar-scanner-msbuild · GitHub.

While waiting for the issue to be resolved, you can try to set the value of sonar.cs.roslyn.ignoreIssues to false as a temprorary workaround.

All the best,
Čaba

Hi @Caba_Sagi

This workaround works fine.
Thank you for your help!

All the best,
Severin

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