I'm reviewing some code written by some ex employees and found this
public abstract class BaseClass<T, M>
where T : BaseClass<T, M>, M
where M : IDisposable
{
protected M PropertyName {get; private set}
...
// T is never used in this class. Only M is used
}
Inherited classes are defined like this
public class InheritedClass : BaseClass<InhertiedClass, IFooInterface>, IFooInterface
{
...
}
IFooInterface : IDisposable {...}
My question is why does base class specify a generic type T that inherits from itself? If I remove this generic constraint then nothing changes, so I was wondering why is it there in the first place? Is there any benefit of specifying generic constraint like this that I'm unaware of?