CC0061: Public MVC Controller actions should not trigger the analyzer
Diagnostic Id: CC0061: Asynchronous method can be terminated with the 'Async' keyword.
Category: Style
Severity: Info
Triggering Code:
using Microsoft.AspNetCore.Mvc; ... public class ForgotPasswordController : Controller { [HttpGet] public async Task<IActionResult> Index() { await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); return View(); } }
When a class inherits from Microsoft.AspNetCore.Mvc.Controller and a public method in the class returns Task<IActionResult> the analyzer should not be triggered. Alternatively if a method is marked with [HttpGet], [HttpPost], etc. the analyzer should not pop.
BUG:
Adding a global suppression with scope NamespaceAndDescendants does not suppress the analyzer.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "CC0061:Asynchronous method can be terminated with the 'Async' keyword.", Justification = "Public Controller Actions do not need to be named with Async.", Scope = "NamespaceAndDescendants", Target = "CPCA.WebUI.Features")]