S6934 Should not apply to abstract controllers

I don’t think this rule should be applied to abstract controller classes:

// Lack of [Route] triggers S6934
public abstract class BaseController : Controller {
    [HttpGet]
    [Route("list")]
    public IActionResult List() {
        // ... load and return items
    }
}

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

UserController has its own Route attribute and therefore exposes /api/user/list which triggers its version of List().
Of course there is no way to enforce setting Route attributes on derived classes, but I think BaseController being abstract could be enough of a hint, especially once the project’s conventions are known.
For reference our project does NOT use conventional routing (bar a couple very specific cases).

1 Like

Hi @m-gallesio. Thank you for reporting this problem. Confirmed as False Positive. I created a Github issue for it, you can use it to track the progress of the fix.