@@ -579,9 +579,9 @@ JavascriptInterop::Invoker(const v8::FunctionCallbackInfo<Value>& iArgs)
579
579
cli::array<System::Object^>^ arguments;
580
580
581
581
// Match arguments & parameters counts. We will add nulls where
582
- // we have imsufficient parameters. Note that this checking does
582
+ // we have insufficient parameters. Note that this checking does
583
583
// not detect where nulls have been supplied (or insufficient parameters
584
- // have been spplied ), but the corresponding parameter cannot accept
584
+ // have been supplied ), but the corresponding parameter cannot accept
585
585
// a null. This will trigger an exception during invocation.
586
586
if (iArgs.Length () <= parametersInfo->Length )
587
587
{
@@ -626,10 +626,32 @@ JavascriptInterop::Invoker(const v8::FunctionCallbackInfo<Value>& iArgs)
626
626
bestMethodArguments = arguments;
627
627
bestMethodMatchedArgs = match;
628
628
}
629
-
629
+ else if (match == bestMethodMatchedArgs)
630
+ {
631
+ if (suppliedArguments->Length == parametersInfo->Length ) // Prefer method with the most matches and the same length of arguments
632
+ {
633
+ bestMethod = method;
634
+ bestMethodArguments = arguments;
635
+ bestMethodMatchedArgs = match;
636
+ }
637
+ }
638
+
639
+ /*
640
+ THE CODE BELOW MAY CHOOSE A METHOD PREMATURLY
641
+ for example:
642
+
643
+ public void test(string a, int b, bool c) { ... }
644
+ public void test(string a, int b, bool c, float d) { ... }
645
+
646
+ and then invoke it this way in JavaScript:
647
+
648
+ test("some text", 1234, true, 3.14);
649
+
650
+ it'll invoke the first one instead of the second because it found 3 matches and there are 3 arguments.
651
+ */
630
652
// skip lookup if all args matched
631
- if (match == arguments->Length )
632
- break ;
653
+ // if (match == arguments->Length)
654
+ // break;
633
655
}
634
656
}
635
657
}
0 commit comments