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

Build in AuthenticationStateProvider breaks after trimming #56207

Closed
1 task done
iits-timon-holzhaeuser opened this issue Jun 12, 2024 · 5 comments · Fixed by #56878
Closed
1 task done

Build in AuthenticationStateProvider breaks after trimming #56207

iits-timon-holzhaeuser opened this issue Jun 12, 2024 · 5 comments · Fixed by #56878
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-authentication feature-blazor-wasm-auth feature-trimming
Milestone

Comments

@iits-timon-holzhaeuser
Copy link

iits-timon-holzhaeuser commented Jun 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Just tried the new API from #52769 and replaced my implementation with it.
After the trimming during dotnet publish I get an exception as soon as the app tries to hand over to WebAssembly:
Screenshot 2024-06-12 205246

May relate to #52947 as I noticed that the AuthenticationStateData is using a IList<KeyValuePair<string, string>> but that is only my wild guess.

I'm not using the JSON Source Code Generation Serialization

After removing this line on client:

builder.Services.AddAuthenticationStateDeserialization();

And this line on the server side:

.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true)

The app worked again as expected.

Expected Behavior

The handover to Web Assembly should work flawless.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9.0.0-preview.5.24306.7

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jun 12, 2024
@MackinnonBuck MackinnonBuck added this to the 9.0-preview7 milestone Jun 13, 2024
@MackinnonBuck MackinnonBuck added bug This issue describes a behavior which is not expected - a bug. feature-trimming labels Jun 13, 2024
@mguinness
Copy link

Also try adding the following to PropertyGroup section in the csproj file.

<_ExtraTrimmerArgs>--keep-metadata parametername</_ExtraTrimmerArgs>

@iits-timon-holzhaeuser
Copy link
Author

This fixed the issue, thanks 🎉 Added the Property to the client project, and now it works as expected.

So, most likely this will be fixed by PR dotnet/runtime#102850? Or is this the PR which made the _ExtraTrimmerArgs possible?

@mguinness
Copy link

The PR should obliviate the need for _ExtraTrimmerArgs , maybe @sbomer can clarify further.

@sbomer
Copy link
Member

sbomer commented Jun 14, 2024

Yes, with that PR you should not need --keep-metadata parametername.

I'm not familiar with the scenario though - if this is using JSON serializer without the source generator, you might hit other trimming-related problems. Any warnings you get with SuppressTrimAnalysisWarnings=true are indicative of potential problems.

I'll close this issue because I believe the specific failure is fixed by dotnet/runtime#102850, but feel free to reopen if that's not the case.

@sbomer sbomer closed this as completed Jun 14, 2024
@halter73 halter73 reopened this Jun 26, 2024
@halter73
Copy link
Member

I'm reopening because while there are workarounds, we want to make sure nothing is over-trimmed in the default configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-authentication feature-blazor-wasm-auth feature-trimming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants