File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,8 @@ public void CanInvokeInteropMethods()
107
107
[ "invokeNewWithClassConstructorAsync.dataProperty" ] = "abraka" ,
108
108
[ "invokeNewWithClassConstructorAsync.function" ] = "6" ,
109
109
[ "invokeNewWithNonConstructorAsync" ] = "Success" ,
110
+ // Function reference tests
111
+ [ "changeFunctionViaObjectReferenceAsync" ] = "42"
110
112
} ;
111
113
112
114
var expectedSyncValues = new Dictionary < string , string >
@@ -171,6 +173,8 @@ public void CanInvokeInteropMethods()
171
173
[ "invokeNewWithClassConstructor.dataProperty" ] = "abraka" ,
172
174
[ "invokeNewWithClassConstructor.function" ] = "6" ,
173
175
[ "invokeNewWithNonConstructor" ] = "Success" ,
176
+ // Function reference tests
177
+ [ "changeFunctionViaObjectReference" ] = "42"
174
178
} ;
175
179
176
180
// Include the sync assertions only when running under WebAssembly
Original file line number Diff line number Diff line change 301
301
InvokeNewTests ();
302
302
}
303
303
304
+ await FunctionReferenceAsyncTests ();
305
+
306
+ if (shouldSupportSyncInterop )
307
+ {
308
+ FunctionReferenceTests ();
309
+ }
310
+
304
311
Invocations = invocations ;
305
312
DoneWithInterop = true ;
306
313
}
601
608
}
602
609
}
603
610
611
+ private async Task FunctionReferenceAsyncTests ()
612
+ {
613
+ var funcRef = await JSRuntime .GetValueAsync <IJSObjectReference >(" jsInteropTests.nonConstructorFunction" );
614
+ var testClassRef = await JSRuntime .InvokeNewAsync (" jsInteropTests.TestClass" , " abraka" );
615
+ await testClassRef .SetValueAsync (" getTextLength" , funcRef );
616
+ ReturnValues [" changeFunctionViaObjectReferenceAsync" ] = (await testClassRef .InvokeAsync <int >(" getTextLength" )).ToString ();
617
+ }
618
+
619
+ private void FunctionReferenceTests ()
620
+ {
621
+ var inProcRuntime = ((IJSInProcessRuntime )JSRuntime );
622
+
623
+ var funcRef = inProcRuntime .GetValue <IJSObjectReference >(" jsInteropTests.nonConstructorFunction" );
624
+ var testClassRef = inProcRuntime .InvokeNew (" jsInteropTests.TestClass" , " abraka" );
625
+ testClassRef .SetValue (" getTextLength" , funcRef );
626
+ ReturnValues [" changeFunctionViaObjectReference" ] = testClassRef .Invoke <int >(" getTextLength" ).ToString ();
627
+ }
628
+
604
629
public class PassDotNetObjectByRefArgs
605
630
{
606
631
public string StringValue { get ; set ; }
You can’t perform that action at this time.
0 commit comments