File tree 2 files changed +20
-3
lines changed
Tests/Noesis.Javascript.Tests
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -692,10 +692,17 @@ JavascriptInterop::Invoker(const v8::FunctionCallbackInfo<Value>& iArgs)
692
692
693
693
if (members->Length > 0 && members[0 ]->MemberType == System::Reflection::MemberTypes::Method)
694
694
{
695
+ int maxParameters = 0 ;
696
+ for (int i = 0 ; i < members->Length ; i++)
697
+ {
698
+ System::Reflection::MethodInfo^ method = (System::Reflection::MethodInfo^) members[i];
699
+ maxParameters = System::Math::Max (maxParameters, method->GetParameters ()->Length );
700
+ }
701
+
695
702
// parameters
696
- suppliedArguments = gcnew cli::array<System::Object^>(iArgs. Length () );
703
+ suppliedArguments = gcnew cli::array<System::Object^>(maxParameters );
697
704
ConvertedObjects already_converted;
698
- for (int i = 0 ; i < iArgs. Length () ; i++)
705
+ for (int i = 0 ; i < maxParameters ; i++)
699
706
suppliedArguments[i] = ConvertFromV8 (iArgs[i], already_converted);
700
707
701
708
// look for best matching method
@@ -710,7 +717,7 @@ JavascriptInterop::Invoker(const v8::FunctionCallbackInfo<Value>& iArgs)
710
717
// not detect where nulls have been supplied (or insufficient parameters
711
718
// have been supplied), but the corresponding parameter cannot accept
712
719
// a null. This will trigger an exception during invocation.
713
- if (iArgs. Length () <= parametersInfo->Length )
720
+ if (suppliedArguments-> Length <= parametersInfo->Length )
714
721
{
715
722
int match = 0 ;
716
723
int failed = 0 ;
Original file line number Diff line number Diff line change @@ -201,6 +201,16 @@ public void MethodCallWithoutParameters()
201
201
result . Should ( ) . Be ( 1 ) ;
202
202
}
203
203
204
+ [ TestMethod ]
205
+ public void MethodCallWithoutParameters_RedundantArgumentsAreIgnored ( )
206
+ {
207
+ var obj = new TypedPropertiesClass ( ) ;
208
+ _context . SetParameter ( "obj" , obj ) ;
209
+ var result = _context . Run ( "obj.methodWithoutParameters(42)" ) ;
210
+
211
+ result . Should ( ) . Be ( 1 ) ;
212
+ }
213
+
204
214
[ TestMethod ]
205
215
public void MethodCallWithParameter ( )
206
216
{
You can’t perform that action at this time.
0 commit comments