.NET Analyzer supports concurrent execution (and more C#9)

Hi .NET Developers

.NET Analysis now has an option to enable concurrent execution that can significantly reduce analysis time. It can be enabled by setting the environment variable SONAR_DOTNET_ENABLE_CONCURRENT_EXECUTION to true. Whilst this has not caused any issues in our testing, we will not enable this by default until we are satisfied that there are no issues “in the wild”. Please let us know if you have tried this setting, we’d love to receive your feedback, good or bad.

This release also includes more support for analysing the new features of C#9. See the release notes for more details.

These changes are available now on SonarCloud and will be included in SonarQube 9.1.

Thanks

Tom

4 Likes

Has this been pushed out to the global tool yet? I’m trying to run it in my GitHub Actions workflow, which as you can see from the logs below, the environment variable is set, but Sonar is still saying it’s disabled:

Sat, 04 Sep 2021 18:51:55 GMT
Run dotnet-sonarscanner end /d:sonar.login="***"
Sat, 04 Sep 2021 18:51:55 GMT   dotnet-sonarscanner end /d:sonar.login="***"
Sat, 04 Sep 2021 18:51:55 GMT   shell: /usr/bin/bash -e {0}
Sat, 04 Sep 2021 18:51:55 GMT   env:
Sat, 04 Sep 2021 18:51:55 GMT     DOTNET_ROOT: /home/runner/.dotnet
Sat, 04 Sep 2021 18:51:55 GMT     GITHUB_TOKEN: ***
Sat, 04 Sep 2021 18:51:55 GMT     SONAR_DOTNET_ENABLE_CONCURRENT_EXECUTION: true
Sat, 04 Sep 2021 18:51:55 GMT SonarScanner for MSBuild 5.3.1
Sat, 04 Sep 2021 18:51:55 GMT Using the .NET Core version of the Scanner for MSBuild
Sat, 04 Sep 2021 18:51:55 GMT Post-processing started.
...

Sat, 04 Sep 2021 18:52:38 GMT INFO: Sensor C# Analysis Log [csharp]
Sat, 04 Sep 2021 18:52:38 GMT INFO: Roslyn version: 3.11.0.0
Sat, 04 Sep 2021 18:52:38 GMT INFO: Language version: CSharp9
Sat, 04 Sep 2021 18:52:38 GMT INFO: Concurrent execution: disabled
Sat, 04 Sep 2021 18:52:38 GMT INFO: Sensor C# Analysis Log [csharp] (done) | time=5ms
Sat, 04 Sep 2021 18:52:38 GMT INFO: Sensor C# Properties [csharp]
Sat, 04 Sep 2021 18:52:38 GMT INFO: Sensor C# Properties [csharp] (done) | time=1ms
...

Hi Steve

Yes, as long as you are using Sonarcloud the scanner should have downloaded the latest analyzer. I’m guessing this is the case otherwise I wouldn’t expect to see the ‘Concurrent Execution’ log line at all. I’ve just tried to replicate your problem without success. Could you post as much of your GH Action as possible without revealing anything sensitive so that we can get a better idea of your setup.

Thanks

Tom

Here’s an OSS repo where I tried the same thing this morning with the same result:

Hi Steve

Thanks for posting the repo. I can see that you set the environment variable in the end step. For .NET, as we have a Roslyn analyser, the analysis happens during the build, so this is too late. The following fixes the problem.

- name: Build
      run: dotnet build --no-restore
      env:
        SONAR_DOTNET_ENABLE_CONCURRENT_EXECUTION: true

Hope that helps

Thanks

Tom

1 Like

Ack, I didn’t realize the .NET scanner was a Roslyn analyzer – that makes sense!

Hi @SteveDesmond.ca and anyone else who has tried concurrent execution,

Could you let us know how you are getting on with it?
Have you encountered any problems?
Have you noticed performance improvements?

Thanks

Tom

6 posts were split to a new topic: Analysis of .NET Project Timing Out

Hi Folks

In SonarCloud and in the next release of SonarQube (9.5) concurrent execution is on by default. We’ve found that this usually results in a small reduction in analysis time. If for any reason you suspect that it is causing problems you can still turn it off using the environment variable described above.

Thanks

Tom

A post was split to a new topic: SonarCloud .NET build performance issue