Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC0061: Public MVC Controller actions should not trigger the analyzer #1042

Open
hellfirehd opened this issue Mar 28, 2020 · 0 comments
Open

Comments

@hellfirehd
Copy link

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")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant