-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
hi,
with the usage of dependency injection and the nameof directive, we are heavy repeating the class name,
and if we have several classes, lets say for example: "controllers/services/repositories" that are similar in functionality, then we we shall copy and paste the hole class and change its name then change all reference to the old class in the new class.
and this might lead to a lot of errors and forgetness.
so is it feasible to make:
TThis to be changed at compile time to the current class it is used inside it.
TParent to be changed at compile time to the current class parent it is used inside it.
code before:
`
public class ContinueController : Controller
{
readonly ILogger _logger;
public ContinueController(ILogger<ContinueController> logger_)
{
_logger = logger_;
Debug.WriteLine(nameof(ContinueController) + "_Entered");
Debug.WriteLine(nameof(Controller) + "_Parent");
}
}
`
code after:
`
public class ContinueController : Controller
{
readonly ILogger _logger;
public ContinueController(ILogger<TThis> logger_ )
{
_logger = logger_;
Debug.WriteLine(nameof(TThis) + "_Entered");
Debug.WriteLine(nameof(TParent) + "_Parent");
}
}
`