Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic C# API Clients - Nested interfaces inheriting IRemoteService #4280

Closed
NecatiMeral opened this issue Jun 9, 2020 · 1 comment · Fixed by #4345
Closed

Dynamic C# API Clients - Nested interfaces inheriting IRemoteService #4280

NecatiMeral opened this issue Jun 9, 2020 · 1 comment · Fixed by #4345
Assignees
Milestone

Comments

@NecatiMeral
Copy link
Contributor

NecatiMeral commented Jun 9, 2020

Hi,

I'm experiencing a issue when using nested interfaces for application services.

Example:
Step 1: Create convenience interface for CRUD application services

public namespace Example 
{
    public interface IHierarchyCrudAppService<
                TEntityDto,
                in TKey,
                in TGetListInput,
                in TCreateInput,
                in TUpdateInput> 
            : ICrudAppService<
                TEntityDto,
                TKey,
                TGetListInput,
                TCreateInput,
                TUpdateInput>
        {
            Task<ListResultDto<TEntityDto>> FindChildrenAsync(TKey? parentId, bool recursive = false);
    
            Task MoveAsync(TKey id, TKey? newParentId);
        }
}

Step 2 (should be optional for repro): Create service implementation

Step 3: Try to initialize abp module with Dynamic C# API Clients.

Observation:
The module fails to initialize because it cannot assign the generic interface:

System.Reflection.TargetInvocationException

The type 'Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1[Example.IHierarchyCrudAppService5[TEntityDto,TKey,TGetListInput,TCreateInput,TUpdateInput]]' is not assignable to service 'Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1'.

Workaround:
To continue my work, I've removed the convenience interface from my Application.Contracts project and directly added the interface signature to my application services / definitions.

Solution proposal:
I've located the source of this behavior at Volo.Abp.Http.Client > ServiceCollectionDynamicHttpClientProxyExtensions @ L48.

A solution can be a customizable type filter (as the todo says) or a negotiation interface, to explicitly exclude a interface, but not it's inherited interfaces.

@hikalkan
Copy link
Member

I think we should ignore generic interfaces for application service interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants