Something like self-restraint will allow you to expose derived types while holding back:
abstract class Foo<T> where T : Foo<T> { protected abstract void Process(FooProcessor<T> processor); }
Then derived types define themselves as a target:
class FooChild : Foo<FooChild> { protected override void Process(FooProcessor<FooChild> processor) { } }
Please note that this design tends to have only a small set of uses. In addition, you lose the ability to refer to Foo as a base without specifying its general type.
There is also a blog post from Eric Lippert about how to abuse this design, so you might consider what it is that you are actually trying to accomplish by wanting your protected method to reference the derived class directly.
You might be better off using interfaces to encapsulate the behavior you are trying to achieve.
source share