LostBeard / SpawnDev.BlazorJS

Full Blazor WebAssembly and Javascript Interop with multithreading via WebWorkers
https://blazorjs.spawndev.com
MIT License
78 stars 6 forks source link

Call to WebWorker service method with multiple signatures not working as expected #23

Closed jbrown29 closed 7 months ago

jbrown29 commented 7 months ago

Could you update the documentation for blazor worker to show that each function names must be unique with unique signatures. Even though the compiler allows same function names, with different signatures, your plugin does not due to (presumably) limitations set by the way things are serialized.

An example that I ran into that appears to fail is...

//FAIL public interface IContractService { public Task<byte[]> DoThis(string value); public Task<byte[]> DoThis(double value); }

//SUCCESS public interface IContractService { public Task<byte[]> DoThis(string value); public Task<byte[]> DoThat(double value); }

console log of error:

ERROR: MessageEvent {isTrusted: true, data: {…}, origin: '', lastEventId: '', source: null, …} VM8:3 ERROR: Exception has been thrown by the target of an invocation. VM8:3 ERROR stacktrace: at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) VM8:3 at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) VM8:3 at SpawnDev.BlazorJS.IJSInProcessRuntimeExtensions.Invoke(IJSInProcessRuntime _js, Type returnType, String identifier, Object[] args) VM8:3 at SpawnDev.BlazorJS.JSInterop.Get(Type returnType, IJSInProcessObjectReference targetObject, Int32 identifier) VM8:3 at SpawnDev.BlazorJS.IJSInProcessObjectReferenceExtensions.Get(IJSInProcessObjectReference targetObject, Type returnType, Int32 identifier) VM8:3 at SpawnDev.BlazorJS.WebWorkers.ServiceCallDispatcher.PostDeserializeArgs(String requestId, MethodInfo methodInfo, Int32 argsLength, Func`3 getArg) VM8:3 at SpawnDev.BlazorJS.WebWorkers.ServiceCallDispatcher._worker_OnMessage(MessageEvent e)

LostBeard commented 7 months ago

This bug is now fixed in WebWorkers Nuget version 2.2.32.

Thank you for reporting this issue.