Here's a simplified example that doesn't compile.
public class T1Class
{
}
public class Test<T> where T : T1Class
{
public Test(IRepository repository)
{
repository.SavingT1Class(this);
}
}
public interface IRepository
{
void SavingT1Class(Test<T1Class> test);
}
I find it strange that the compiler cannot infer that the Test< T> class that I'm sending into SavingT1Class(Test< T1Class> test) is actually Test< T1Class> because I've defined T as T1Class. And cannot "convert" the T into TClass.
Any Ideas how I can make the compiler understand that 'this' is actually Test< T1Class> without adding generics to IRepository itself?