C# ConfigureAwait(false) rule csharpsquid:S3216 not producing codesmells

Setup used:

  • Azure devops cloud hosted code
  • Azure devops cloud hosted agents
  • Sonarcloud buildtasks using azure devops cloud pipeline (classic pipeline)
  • Rule: csharpsquid:S3216

During analysis of a C# project dotnet core 3.1 in azure devops using sonarcloud build steps we on do get analysis comments during PR’s but this ConfigureAwait(false) rule seem to not trigger.

Here is the new code which was analyse and to my knowledge it should add in configureawait on all 3 implementations?

        public async Task<SmsEnterpriseDto> GetEnterpriseDetailsAsync(Guid enterpriseUuid)
            var enterprise = await SmsHubRepository.GetByIdAsync(enterpriseUuid.ToString());
            return enterprise == null || enterprise.Id == default ? null : Mapper.Map<SmsEnterpriseDto>(enterprise);

        public async Task<CrudResult> UpdateEnterpriseAsync(SmsEnterpriseDto enterpriseDto)
            if (enterpriseDto == null)
                return CrudResult.NoEntity;

            var enterprise = await SmsHubRepository.GetByIdAsync(enterpriseDto.Id.ToString());
            if (enterprise != null && enterprise.Id != default )
                return await SmsHubRepository.UpdateAsync(enterprise);
            return CrudResult.NoEntity;

Hi @hellmanf

This rule only raises for .Net framework libraries as .Net core does not have a SynchronizationContext.
Unfortunately the fact that it only raises for .Net framework is not documented, so I will update the documentation for the rule.

@Caba_Sagi aaah okay, is there the same configureawait “requirement” need in dotnet core or is await state different in core vs framework?

If yes, its the same need, is there any plans to make such a rule or extend existing to include core code?

@hellmanf I suggest you to take a look at the following blogpost about ConfigureAwait FAQ.
Currently, we do not plan on extending this rule for .Net Core.