I have a base class, with a method, where I would like to use generics to force the coder to use a generic expression on the current class:
public class TestClas
Make the base class itself generic:
public class TestClass where T : TestClass
{
public void DoStuffWithFuncRef(Expression> expression)
{
this.DoStuffWithFuncRef(Property.NameFor(expression));
}
}
and derive from it:
public class SubTestClass : TestClass {
// ...
}
If you need to have an inheritance hierarchy with a single root, inherit the generic base class from another non-generic version:
public class TestClass { ... }
public class TestClass : TestClass where T : TestClass
Of course you should probably make the base classes abstract.