-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
When exporting a .NET async method that returns Task<ArraySegment<byte>> or Task<Array>, error SYSLIB1072 is reported.
Exporting a .NET method that returns ArraySegment<byte> or Array works.
Reproduction Steps
dotnet new wasmbrowser- Add
<LangVersion>preview</LangVersion>to<PropertyGroup>in thecsprojfile - In
Program.cs, add the following namespaces:
using System.Threading.Tasks;
using System.IO;- Inside
public partial class MyClassinProgram.cs, add the following code:
[JSExport]
[return: JSMarshalAs<JSType.MemoryView>]
static ArraySegment<byte> GetMemoryView() {
var stream = new MemoryStream();
stream.TryGetBuffer(out var buffer);
return buffer;
}
[JSExport]
[return: JSMarshalAs<JSType.Promise<JSType.MemoryView>>]
static Task<ArraySegment<byte>> GetMemoryViewAsync() => Task.Run(GetMemoryView);
[JSExport]
static byte[] GetBytes() => new byte[0];
[JSExport]
static Task<byte[]> GetBytesAsync() => Task.FromResult(GetBytes());dotnet run
Expected behavior
The build should be successful
Actual behavior
error SYSLIB1072: The type 'System.Threading.Tasks.Task<System.ArraySegment<byte>>' is not supported by source-generated JavaScript interop. The generated source will not handle marshalling of the return value of method 'GetMemoryViewAsync'.
error SYSLIB1072: The type 'System.Threading.Tasks.Task<byte[]>' is not supported by source-generated JavaScript interop. The generated source will not handle marshalling of the return value of method 'GetBytesAsync'.
Regression?
No response
Known Workarounds
No response
Configuration
.NET 7 RC2
Windows 10 Professional x64 21H2 Build 19044.2130
Other information
No response