0

I have this type constraint

where TLookup : ILookupable<ILookup>

And I'm passing this interface for the type

public interface IEmployeeProxy : ILookupableCode

Where you have

public interface ILookupableCode : ILookupable<ILookupCode>

And

public interface ILookupable<T> where T : ILookup
{
    Task<IEnumerable<T>> LookupByNameAsync(string name, int take = 5, int skip = 0);

    Task<T> LookupByIdAsync(long id);
}

And

public interface ILookupCode : ILookup

But I'm getting the There is no implicit reference conversion error and I don't know why, because for me IEmployeeProxy is

IEmployeeProxy => ILookupableCode => ILookupable<ILookupCode> => ILookupable<ILookup>

What I'm doing wrong here? Why I'm getting this error? For me looks like I should work.

If you want to know why I'm doing this, is because I want to have ILookupable with some methods that return ILookup, but also have ILookupableCode with the same methods of ILookupable that will return ILookupCode and a few more things too.

enet
  • 41,195
  • 5
  • 76
  • 113
Vencovsky
  • 28,550
  • 17
  • 109
  • 176

1 Answers1

0

So the way to fix this would be change the signature of ILookupable to ILookupable<out T> but this comes with another problem what to do that, my methods need to return an interface type. So this makes impossible to have a method with return type Task<T> .

The only walkaround this is using this third party implementation of ITask.

Vencovsky
  • 28,550
  • 17
  • 109
  • 176