Skip to content

IndexOutOfRange exception in JSImportGenerator #121109

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
In the C# of a Blazor WebAssembly project (.NET 8):

[JSImport ("MyFunction", "ModuleName")]
[return: JSMarshalAs<JSType.Promise<JSType.Any>> ()]
public static partial Task MyFunction(string arg);

to import the JavaScript function:

export async function MyFunction(arg) {
}

The C# declaration is incorrect and should read JSType.Promise<JSType.Void>. The JSImportGenerator does not report that error, but instead crashes with an IndexOutOfRange exception. As there currently is no indication why JSImportGenerator crashes, it is quite hard to find which of the many JSImport is incorrect.

It would be nice if the JSImportGenerator would report an error about the mismatch of JSType.Any and Task not having a generic type argument.


Original Comments

Feedback Bot on 10/27/2025, 04:46 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions