Astn/JSON-RPC.NET

Allow ignored parameters from client

dawesc opened this issue · 4 comments

There are some methods where my client application is sending too many parameters from the client and i'd just like these to be ignored if possible. How would you feel about about a config property AllowIgnoredParameters that would default to False but could be used then to bypass the exception on 317 of Handler.cs? Many thanks, Christopher

Astn commented

Would you do this per method, or globally?

It was a global config option i was thinking of because methods can have optional parameters already which could take care of the same issue.

Not sure whether it's helpful, but I had a related problem where a single method would have unknown parameters by design (reflection based plugin framework accessed through JSON).

I solved this using standard .net params:

[JsonRpcMethod] private externalDataTypes.Result executeCommand(String targetId, String command, params object[] parameters) {

You define required parameters as normal, and then catch anything afterwards as params object. It doesn't solve your problem because you'd most likely have to make some changes to your client request serialisation. However if it's a common thing, you could try this approach as it gives you the flexiblity per method, and doesn't require loss of method signature enforcement everywhere.

Ah interesting idea, this time round i've solved it on client side with a magic suppression routine so the methods that were passing too many parameters simply suppress parameters that shouldn't be sent but better understanding the method prototypes rather than simply GIGO :-) many thanks