The analyzer is currently lacking the possibility to ban a type when used as a base class.
This is usefull when in a system the developers should not inherit from a specific base class (because i.e. there is a better strategy to obtain the same purpose), but such base class:
cannot be marked as "obsolete" to prevent its usage
cannot be marked as "sealed" to prevent it being inherited
can be legitimately used in other contexts, so simply banning it would be overkill due to the vast number of false-positives
Describe suggestions on how to achieve the rule
The syntax can be the same already used for banning types, but instead of something like this:
This idea came to me when in a project I was working on, the "Hub" class mustn't be used to inherit new SignalR Hubs (because only one "global" SignalR Hub was allowed into the system, and new functionalities had to be implemented into such "global" SignalR Hub instead of distributing them into new distinct SignalR Hub classes)
Analyzer
Diagnostic ID: RS0030
Describe the improvement
The analyzer is currently lacking the possibility to ban a type when used as a base class. This is usefull when in a system the developers should not inherit from a specific base class (because i.e. there is a better strategy to obtain the same purpose), but such base class:
Describe suggestions on how to achieve the rule
The syntax can be the same already used for banning types, but instead of something like this:
T:Microsoft.AspNetCore.SignalR.Hub; blah blah blah
use a different prefix, like
BT
BT:Microsoft.AspNetCore.SignalR.Hub; blah blah blah
Additional context
This idea came to me when in a project I was working on, the "Hub" class mustn't be used to inherit new SignalR Hubs (because only one "global" SignalR Hub was allowed into the system, and new functionalities had to be implemented into such "global" SignalR Hub instead of distributing them into new distinct SignalR Hub classes)