Skip to content

System.Runtime.InteropServices.JavaScript.Runtime is not linker-safe #37775

@eerhardt

Description

@eerhardt

We recently introduced a JavaScript.Runtime class with methods like the following:

public static int BindJSObject(int jsId, int mappedType)
{
JSObject? obj;
lock (_boundObjects)

These methods are invoked through JS code here:

var namespace = "System.Runtime.InteropServices.JavaScript";
var classname = binding_fqn_class.length > 0 ? binding_fqn_class : "Runtime";

this.bind_js_obj = get_method ("BindJSObject");
this.bind_core_clr_obj = get_method ("BindCoreCLRObject");
this.bind_existing_obj = get_method ("BindExistingObject");
this.unbind_js_obj = get_method ("UnBindJSObject");

However, the linker doesn't know that these methods need to be preserved, so it is trimming them out. Thus, a trimmed Blazor app doesn't load successfully.

We should enable it so these methods are preserved by the linker.

cc @marek-safar @lewing

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions