Controller class name should be suffixed with 'Controller'

Rule ND2021 Naming Conventions

Warns about ASP.NET Controller classes not suffixed with Controller, a recommended practice: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/actions ControllerBase is also accepted for base classes.

How to fix

Suffix the names of matched Controller classes with Controller.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Controller class name should be suffixed with 'Controller'</Name>
// <Id>ND2021:ControllerClassNameShouldBeSuffixedController </Id>

warnif count > 0 from t in Application.Types where 
  (t.DeriveFrom("Microsoft.AspNetCore.Mvc.Controller".AllowNoMatch()) ||
   t.DeriveFrom("Microsoft.AspNetCore.Mvc.ControllerBase".AllowNoMatch()) ||
   t.HasAttribute("Microsoft.AspNetCore.Mvc.ControllerAttribute".AllowNoMatch()))
   &&
  
  // We use SimpleName, because in case of generic Exception type
  // SimpleName suppresses the generic suffix (like <T>).
 !t.SimpleNameLike(@"Controller$") &&
 !t.SimpleNameLike(@"ControllerBase$") // Allow the second suffix Base
                                       // for base Controller classes.
select new {
   t,
   Debt = 5.ToMinutes().ToDebt(),
   Severity = Severity.High
}

//<Expl>
// The *controller {0}'s name* should be suffixed with *Controller*.
// This is required in the *Microsoft* documentation.
//</Expl>

//<Desc>
// Warns about *ASP.NET Controller classes* not suffixed with
// **Controller**, a recommended practice:
// https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/actions
// **ControllerBase** is also accepted for base classes.
//</Desc>

//<HowToFix>
// Suffix the names of matched Controller classes with **Controller**.
//</HowToFix>

Naming Conventions: all 23 items