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.