fix for optional parameters#108
Conversation
when only the second or third optional parameter is used during a JsonRequest, the JsonException "invalid parameters" was triggerd now fixed => place of optional parameter in declaration of JsonRpcMethod doesn't matter anymore
|
is this useful for the project? |
|
Hi, @HoMS1987 This does look like it may be useful. How would I reproduce the issue? I need to have tests for what we are fixing here. |
|
@HoMS1987 There are some tests for optional parameters here: https://github.com/Astn/JSON-RPC.NET/blob/master/AustinHarris.JsonRpcTestN/Test.cs#L1074 Could you add one that demonstrates he issue? |
|
The method where the error occured was similar to this: The test cases would be like: |
|
The problem is, I have several optional datatypes. The params of the request don't have the same order like in the method. In my case it's not working when I get the first and third optional parameter, the second I don't get. When I remember correct (the pull request is some months old^^) it's because in C# when you have a method with optional parameters, you can't just call it with the first and third optional parameter. It depends on the order of the implementation of the method. So if the json request only has the first and third optional parameter you automatically have to add the default value for the second optional parameter. and that's what I did in the pull request. |
|
Gotcha, I'll check it out. Thanks for the PR! |
|
There were a few tests covering some edge cases that were not passing with this solution, so I had to take a slightly different approach to the problem to keep all the tests passing. See PR #119 Again thanks for all your work on this issue! |
when only the second or third optional parameter is used during a JsonRequest, the JsonException "invalid parameters" was triggerd
now fixed => place of optional parameter in declaration of JsonRpcMethod doesn't matter anymore