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

Go To HandlR not worked when handler class use inherited IRequestHandler #65

Open
aalirezamoradii opened this issue Jul 24, 2024 · 3 comments

Comments

@aalirezamoradii
Copy link

aalirezamoradii commented Jul 24, 2024

public interface ISharedCommandHandler<in TRequest, TResponse> : IRequestHandler<TRequest, Dto<TResponse>> where TRequest : IRequest<Dto<TResponse>>

public class XCommandRequest : IRequest<XCommandResponse> {}
public class XCommandResponse {}

public class XCommandHandler : ISharedCommandHandler<XCommandRequest, XCommandResponse>
{
    public async Task<Dto<XCommandResponse>> Handle(XCommandRequest request, , CancellationToken cancellationToken) {}
}

Go to handlR not working

@kzryzstof
Copy link
Owner

@aalirezamoradii Thanks for reporting the issue. Would it be possible for you to update the sample you provided? As of now, I get an error on the XCommandHandler stating that:

The type 'XCommandRequest' must be convertible to 'MediatR.IRequest<Dto<XCommandResponse>>' in order to use it as parameter 'TRequest' in the generic interface 'ISharedCommandHandler<in TRequest,TResponse>'

I do not want to make any assumptions while trying to fix this :)

@aalirezamoradii
Copy link
Author

aalirezamoradii commented Jul 24, 2024

@kzryzstof

public interface ISharedCommandHandler<in TRequest, TResponse> : IRequestHandler<TRequest, Dto<TResponse>> where TRequest : IRequest<Dto<TResponse>>

public class XCommandRequest : IRequest<Dto<XCommandResponse>> {}
public class XCommandResponse {}

public class XCommandHandler : ISharedCommandHandler<XCommandRequest, XCommandResponse>
{
    public async Task<Dto<XCommandResponse>> Handle(XCommandRequest request, , CancellationToken cancellationToken) {}
}

Yes, I have made a mistake
Thanks for respond

@kzryzstof
Copy link
Owner

Thanks! I am now able to reproduce the problem and will try to fix it as soon as possible.

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

No branches or pull requests

2 participants