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

Fix S6934 FP: Abstract Controller base class #9252

Closed
zsolt-kolbay-sonarsource opened this issue May 3, 2024 · 0 comments · Fixed by #9253
Closed

Fix S6934 FP: Abstract Controller base class #9252

zsolt-kolbay-sonarsource opened this issue May 3, 2024 · 0 comments · Fixed by #9253
Assignees
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@zsolt-kolbay-sonarsource
Copy link
Contributor

Description

S6934 raises an issue when the Route attribute isn't added to an abstract Controller class (but it's added to one or more of its action methods). This shouldn't happen, as the action method will always be accessed through a non-abstract derived rather than the abstract base class, so the Route attribute only needs to be applied there.

Repro steps

public abstract class BaseController : Controller   // Noncompliant - FP: shouldn't raise on abstract classes
{
    [HttpGet]
    [Route("list")]
    public IActionResult List()                     // Secondary
    {
        // ... load and return items
        return View();
    }
}

[Route("/api/user")]
public sealed class UserController : BaseController
{
    // other controller code
}

Expected behavior

The rule should not raise an issue on the abstract class.

Actual behavior

The rule raises an issue on the abstract Controller class.

Related information

  • C#/VB.NET Plugins version: 9.24
  • Visual Studio version: Visual Studio 2022 (17.9.6)
  • Operating System: Windows 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants