Build too slow after increase on LOC

Template for a good bug report, formatted with Markdown:

Versions used

We are using Azure DevOps CI’s tasks to execute Code Analysis on .Net Core solutions on SonarCloud.

dotnet version on build server: 3.1.401

Azure DevOps’ task name: Prepare Analysis Configuration
Version: 1.17.0

Azure DevOps’ task name: .NET Core
Version: 2.181.0

Problem observed

The build’s duration of a specific project is approximately 4 minutes when one of its .cs file has 17k LOC (lines of code). However, after changing it to 40k LOC, the duration increase to almost 20 minutes! The only difference is the increase on this .cs file. I have reproduced this behavior and see it: if I change the LOC to 17k the duration comes back to 4 minutes. If it has 40 LOC, the build time increase to 20 minutes.

To be sure that it is related to Sonar, I had removed the SonarPrepareAnalysis from my pipeline and run again my build. So, I noted that the build takes just 30s without Sonar tasks.


Hello @marceloabreu and welcome to our community forum!

Please accept my apologies for the late reply, this slipped under our radar.

We are aware that our analysis doesn’t work very well on very large files. We recently made a change ( #4318) to improve performance when very large files are present, and it will be included in our next sonar-dotnet release (in 2-3 weeks).

Just to be sure that this fix will make your life easier once it gets deployed, could you please measure the Roslyn analyzers performance for the two scenarios (file with 17k LOCs, file with 40k LOCs) and share them with us?

To do that, after the BEGIN step, when building, use the reportanalyzer MSBuild parameter

    msbuild /p:reportanalyzer=true /v:d > build.log

If you want to share them privately, I can send you a private message.

Thank you!