Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void ToJS<T>(Task<T>? value, ArgumentToJSCallback<T> marshaler)
else
{
T result = task.Result;
ToJS(result);
marshaler(ref this, result);
slot.ElementType = slot.Type;
slot.Type = MarshalerType.TaskResolved;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,32 @@ public async Task JsExportTaskOfInt(int value)
//GC.Collect();
}

[Theory]
[MemberData(nameof(MarshalBigInt64Cases))]
public async Task JsExportTaskOfLong(long value)
{
TaskCompletionSource<long> tcs = new TaskCompletionSource<long>();
var res = JavaScriptTestHelper.invoke1_TaskOfLong(tcs.Task, nameof(JavaScriptTestHelper.AwaitTaskOfInt64));
tcs.SetResult(value); // unresolved task marshalls promise and resolves on completion
await Task.Yield();
var rr = await res;
await Task.Yield();
Assert.Equal(value, rr);
}

[Theory]
[MemberData(nameof(MarshalBigInt64Cases))]
public async Task JsExportCompletedTaskOfLong(long value)
{
TaskCompletionSource<long> tcs = new TaskCompletionSource<long>();
tcs.SetResult(value); // completed task marshalls value immediately
var res = JavaScriptTestHelper.invoke1_TaskOfLong(tcs.Task, nameof(JavaScriptTestHelper.AwaitTaskOfInt64));
await Task.Yield();
var rr = await res;
await Task.Yield();
Assert.Equal(value, rr);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWasmThreadingSupported))]
public void JsExportCallback_FunctionIntInt()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ public static Exception EchoException([JSMarshalAs<JSType.Error>] Exception arg1
[JSImport("invoke1", "JavaScriptTestHelper")]
[return: JSMarshalAs<JSType.Promise<JSType.Number>>]
internal static partial Task<int> invoke1_TaskOfInt([JSMarshalAs<JSType.Promise<JSType.Number>>] Task<int> value, [JSMarshalAs<JSType.String>] string name);

[JSImport("invoke1", "JavaScriptTestHelper")]
[return: JSMarshalAs<JSType.Promise<JSType.BigInt>>]
internal static partial Task<long> invoke1_TaskOfLong([JSMarshalAs<JSType.Promise<JSType.BigInt>>] Task<long> value, [JSMarshalAs<JSType.String>] string name);
[JSImport("returnResolvedPromise", "JavaScriptTestHelper")]
internal static partial Task ReturnResolvedPromise();

Expand All @@ -462,6 +464,14 @@ public static async Task<object> AwaitTaskOfObject([JSMarshalAs<JSType.Promise<J
return res;
}

[JSExport]
[return: JSMarshalAs<JSType.Promise<JSType.BigInt>>]
public static async Task<long> AwaitTaskOfInt64([JSMarshalAs<JSType.Promise<JSType.BigInt>>] Task<long> arg1)
{
var res = await arg1;
return res;
}

#endregion

#region Action + Func
Expand Down
Loading