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

Fixed type fetching in the part passed to MessagePack. #73

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/MessagePipe.Interprocess/Workers/NamedPipeWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ async void RunReceiveLoop(Stream pipeStream, Func<CancellationToken, Task>? wait
try
{
var t = AsyncRequestHandlerRegistory.Get(reqTypeName, resTypeName);
var interfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"));
var coreInterfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"));
var interfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var coreInterfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var service = provider.GetRequiredService(interfaceType); // IAsyncRequestHandler<TRequest,TResponse>
var genericArgs = interfaceType.GetGenericArguments(); // [TRequest, TResponse]
var request = MessagePackSerializer.Deserialize(genericArgs[0], message.ValueMemory, options.MessagePackSerializerOptions);
Expand Down
6 changes: 4 additions & 2 deletions src/MessagePipe.Interprocess/Workers/TcpWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ async void RunReceiveLoop(SocketTcpClient client)
try
{
var t = AsyncRequestHandlerRegistory.Get(reqTypeName, resTypeName);
var interfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"));
var coreInterfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"));
var interfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var coreInterfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var service = provider.GetRequiredService(interfaceType); // IAsyncRequestHandler<TRequest,TResponse>
var genericArgs = interfaceType.GetGenericArguments(); // [TRequest, TResponse]
// Unity IL2CPP does not work(can not invoke nongenerics MessagePackSerializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ async void RunReceiveLoop(Stream pipeStream, Func<CancellationToken, System.Thre
try
{
var t = AsyncRequestHandlerRegistory.Get(reqTypeName, resTypeName);
var interfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"));
var coreInterfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"));
var interfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var coreInterfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var service = provider.GetRequiredService(interfaceType); // IAsyncRequestHandler<TRequest,TResponse>
var genericArgs = interfaceType.GetGenericArguments(); // [TRequest, TResponse]
var request = MessagePackSerializer.Deserialize(genericArgs[0], message.ValueMemory, options.MessagePackSerializerOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ async void RunReceiveLoop(SocketTcpClient client)
try
{
var t = AsyncRequestHandlerRegistory.Get(reqTypeName, resTypeName);
var interfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"));
var coreInterfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"));
var interfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var coreInterfaceType = t.GetInterfaces().Where(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"))
.First(x => x.GetGenericArguments().Any(x => x.FullName == header.RequestType));
var service = provider.GetRequiredService(interfaceType); // IAsyncRequestHandler<TRequest,TResponse>
var genericArgs = interfaceType.GetGenericArguments(); // [TRequest, TResponse]
// Unity IL2CPP does not work(can not invoke nongenerics MessagePackSerializer)
Expand Down