The Wayback Machine - https://web.archive.org/web/20220128183114/https://github.com/dotnet/aspnetcore/issues/39839
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSRuntime.Invoke APIs aren't correctly annotated for trimming #39839

Open
pranavkm opened this issue Jan 28, 2022 · 1 comment
Open

JSRuntime.Invoke APIs aren't correctly annotated for trimming #39839

pranavkm opened this issue Jan 28, 2022 · 1 comment

Comments

@pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Jan 28, 2022

Follow up to #39838. JSRuntime's API (excluding the unmarshalled ones) use JSON serialization to serialize the args array and as such are subject to being trimmed away. S.T.Js API for its serialization are annotated with RequiresUnreferencedCode with a recommendation to use the source-generator based overload to avoid this.

Blazor's APIs suppress STJ's warnings (since it happens deep in its bowels) and don't have a trimmer safe alternative. Perhaps one option is to annotate all of the JSRuntime APIs with RequiresUnferencedCode and add an JSRuntime.InvokeAsync overload that accepts exactly one argument a JsonTypeInfo to go with it. Something like so:

TValue IJSRuntime.InvokeAsync<TArg, TValue>(string method, TArg arg, JsonTypeInfo<TArg> t1,  JsonTypeInfo<TValue> t2, CancellationToken cancellationToken)

At the very least, we could require that all code in the framework uses this API for it's interop.

@pranavkm
Copy link
Contributor Author

@pranavkm pranavkm commented Jan 28, 2022

FYI @TanayParikh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants