.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

2 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!