dotnet/aspnetcore

IInvocationBinder throws or returns empty array inconsistently

Open

#63.084 geöffnet am 3. Aug. 2025

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (10.653 Forks)batch import
area-signalrhelp wanted

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

In writing my own IHubProtocol implementation, I found that when a method is invoked, there is no good way to determine whether a method exists with the target name to invoke. As a result, I get unhelpful exceptions thrown.

In particular, while deserializing the invocation request I need the parameter types. I call IInvocationBinder.GetParameterTypes passing in the name of the target method that I have already deserialized. When the method does not exist, it simply returns an empty array, causing my BindArguments method to throw because the number of arguments and the number of parameters mismatch. But that's a red herring. The real issue is that the method itself does not exist at all.

I notice that IInvocationBinder.GetReturnType does throw when the target method does not exist.

Why the two diverging and undocumented policies for these two methods?

What is the best way to handle this?

https://github.com/dotnet/aspnetcore/blob/406950442014149931322f97c42e999ce03fdb71/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs#L2395-L2423

Contributor Guide