S1172 False Positive

  • Operating system: Windows 10
  • IDE name and flavor/env: Visual Studio 2022 Enterprise 64 Bit 17.1.0
  • SonarLint plugin version: 6.1.0.45943
  • Is connected mode used: Yes
    • Connected to SonarQube Community Edition Version 9.3 (build 51899)

Several methods, are reported with unused parameters, such as this simple one, where SonarLinit thinks all four parameters are not used:

private async Task HandleRoleSelectionAsync(Guid personId, Guid roleId, string wtRealm, CancellationToken cancellationToken)
		{
			ClaimsPrincipal claimsPrincipal = HttpContext.User;
			ClaimsIdentity? claimIdentity = claimsPrincipal.Identity as ClaimsIdentity;
			string? authMethod = claimIdentity?.Claims?.FirstOrDefault(x => x.Type == ClaimTypeAuthMethod)?.Value;
			string samAccountName = claimIdentity?.Claims?.FirstOrDefault(x => x.Type == ClaimTypeWindowsAccountName)?.Value ?? Unknown;

			await _service.DeleteRoleSelectionByPersonIdAsync(new Message<Guid>(personId), cancellationToken);
			await _service.InsertRoleSelectionByPersonIdAndRoleIdAsync(new InsertRoleSelectionRequestMessage(personId, roleId, wtRealm, authMethod, samAccountName), cancellationToken);
		}

Hi

This is probably related to Fix S1172 FP: Raises randomly under VS context · Issue #5491 · SonarSource/sonar-dotnet · GitHub - a fix is under way.

Thanks
Andrei