OpenCover Code Coverage Issue - Only DLLs covered, not C# source files

We are using SonarCloud integrated with Azure DevOps pipelines using the predefined tasks such as SonarCloudPrepare@3, SonarCloudAnalyze@3, SonarCloudPublish@3.

We are using the shared YAML pipeline template ( common template for all services) for Build (C#), Sonarcloud and code coverage(openover). This setup works fine for all services except one service.

  • This coverage report is generated but sonarcloud only displays coverage for DLLs (Library code)
  • The main C# application soruce files analyzed during the build process and Sonar analyze stage, however it does’t reflect as part of opencover anaysis and sonarcloud portal as well.
  • There are no build or pipeline fialures.The issue is isolated to only one service, all others behave as expected.

Though we call the same yaml template, why openover is not displaying the code coverage for .cs soruce file for this particular serivice. Can you please help us to understand/troubleshoot further?

Hello,

Just to clarify, SonarQube itself does not generate coverage reports; instead, it reads and visualises reports created by a coverage tool, such as OpenCover.

If you’re seeing coverage data only for DLL files and not for your main application’s source files in SonarQube—and these source files are also missing from the raw coverage report—it suggests that the configuration of your coverage tool (not SonarQube) is the problem. Unfortunately, we’re not experts in configuring OpenCover for every project scenario. You provide the report, SonarQube reads it :smiley:

Please note that OpenCover is no longer maintained, and its maintainers recommend AltCover as an actively maintained alternative. AltCover produces reports compatible with the sonar.cs.opencover.reportsPaths property in SonarQube, making it a good replacement option to consider.