dotnet / linker

388 stars 126 forks source link

Linker regression in 7.0 (wasm) #3110

Closed javiercn closed 1 year ago

javiercn commented 1 year ago

On a Blazor webassembly app with authentication, the linker in 7.0 seems to be incorrectly trimming the getters of an object that we json serialize. This is the linked output in 7.0

This is the linked output in 6.0

This type is used is passed as an argument to JS interop calls, which are annotated as, so the getters should be preserved (as in 6.0) https://github.com/dotnet/aspnetcore/blob/main/src/JSInterop/Microsoft.JSInterop/src/IJSRuntime.cs#L25 https://github.com/dotnet/aspnetcore/blob/main/src/Shared/LinkerFlags.cs#L13

If you want to reproduce it, you can use dotnet 7 and call dotnet new blazorwasm -au Individual -ho -o BlazorWasmAuth and run dotnet publish on the BlazorWasmAuth/Server project.

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

javiercn commented 1 year ago

/cc @lewing

ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.

Issue Details
On a Blazor webassembly app with authentication, the linker in 7.0 seems to be incorrectly trimming the getters of an object that we json serialize. This is the linked output in 7.0 ![](https://user-images.githubusercontent.com/6995051/201389145-7badc5f6-825c-4ad8-b816-e5b7c393159c.png) This is the linked output in 6.0 ![](https://user-images.githubusercontent.com/6995051/201389153-05bd8006-0110-4dce-961d-f9a109d1490a.png) This type is used is passed as an argument to JS interop calls, which are annotated as, so the getters should be preserved (as in 6.0) https://github.com/dotnet/aspnetcore/blob/main/src/JSInterop/Microsoft.JSInterop/src/IJSRuntime.cs#L25 https://github.com/dotnet/aspnetcore/blob/main/src/Shared/LinkerFlags.cs#L13
Author: javiercn
Assignees: -
Labels: `untriaged`, `area-Tools-ILLink`
Milestone: -
agocke commented 1 year ago

@javiercn Thanks for the bug report. Do you have an example of the call site as well?

javiercn commented 1 year ago

https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs#L111

agocke commented 1 year ago

@sbomer Could you take a look?

agocke commented 1 year ago

@javiercn I've been trying to repro this locally, but I can't seem to get the results you describe. Is there something else I need to pass to dotnet publish?

sbomer commented 1 year ago

@javiercn that callsite looks like it would preserve properties of RemoteAuthenticationResult but not RemoteAuthenticationContext - is there another callsite where you expect RemoteAuthenticationContext to be preserved for serialization?

agocke commented 1 year ago

Closing as it looks like this might not be a bug. If we get more info then we can re-open.