-
-
Notifications
You must be signed in to change notification settings - Fork 459
Description
Hi,
the latest change in Grpc.AspNet causes an AmbiguousMatchException in the MagicOnion library. Specifically, this is related to the change introduced in version:
https://github.com/grpc/grpc-dotnet/releases/tag/v2.76.0
More precisely, it seems to be caused by this PR:
grpc/grpc-dotnet#2634
In this PR, a new overload of the MapGrpcService method was added:
public static GrpcServiceEndpointConventionBuilder MapGrpcService(this IEndpointRouteBuilder builder, ServerServiceDefinition serviceDefinition)
public static GrpcServiceEndpointConventionBuilder MapGrpcService(this IEndpointRouteBuilder builder, Func<IServiceProvider, ServerServiceDefinition> getServiceDefinition)
The problem is located in MagicOnionGrpcServiceMappingContext, in the Map(Type) method.
public void Map(Type t)
{
VerifyServiceType(t);
innerBuilders.Add(new MagicOnionServiceEndpointConventionBuilder((GrpcServiceEndpointConventionBuilder)typeof(GrpcEndpointRouteBuilderExtensions)
.GetMethod(nameof(GrpcEndpointRouteBuilderExtensions.MapGrpcService))!
.MakeGenericMethod(t)
.Invoke(null, [builder])!));
}
There is an attempt to retrieve the MapGrpcService method with IEndpointRouteBuilder parameter via reflection; however, there are now two such methods.
I’m not sure whether there is any workaround that can be applied to bypass the issue without making changes to the library itself.
Kind regards,
Valker