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

[net9-rc2] Trim analysis warning IL2026 using XamlTypeResolver with Compiled Bindings #25199

Closed
tranb3r opened this issue Oct 11, 2024 · 4 comments
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.10 platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@tranb3r
Copy link

tranb3r commented Oct 11, 2024

Description

When using compiled bindings, I get the following trim analysis warning:

D:\MauiAppTestTrimAnalysis\MauiAppTestTrimAnalysis\obj\Release\net9.0-android35.0\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\MainPage.xaml.sg.cs(30,3): 
Trim analysis warning IL2026: 
MauiAppTestTrimAnalysis.MainPage.InitializeComponent(): 
Using member 'Microsoft.Maui.Controls.Xaml.Internals.XamlTypeResolver.XamlTypeResolver(IXmlNamespaceResolver, Assembly)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. 
Loading XAML at runtime might require types and members that cannot be statically analyzed. 
Make sure all of the required types and members are preserved.

Is there a fix or workaround?

Steps to Reproduce

  1. Open repro app (simple app with one binding and x:datatype is set in xaml)
  2. Build app in release mode
  3. Check warnings

Link to public reproduction project repository

https://github.com/tranb3r/Issues/tree/main/MauiAppTestTrimAnalysis

Version with bug

9.0.0-rc.1.24453.9

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

Android 15

Did you find any workaround?

No

Relevant log output

No response

@tranb3r tranb3r added the t/bug Something isn't working label Oct 11, 2024
@PureWeen PureWeen added this to the .NET 9.0 GA milestone Oct 11, 2024
@samhouts samhouts added platform/android 🤖 area-xaml XAML, CSS, Triggers, Behaviors labels Oct 11, 2024
@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 12, 2024
@ninachen03
Copy link

ninachen03 commented Oct 12, 2024

This issue has been verified using Visual Studio 17.12.0 Preview 3(9.0.0-rc.2.24503.2 & 9.0.0-rc.1.24453.9). Can repro this issue at android platform.
Image

StephaneDelcroix added a commit that referenced this issue Oct 15, 2024
github-actions bot pushed a commit that referenced this issue Oct 15, 2024
github-actions bot pushed a commit that referenced this issue Oct 17, 2024
@PureWeen PureWeen moved this from Todo to In Progress in MAUI SDK Ongoing Oct 17, 2024
github-actions bot pushed a commit that referenced this issue Oct 17, 2024
github-actions bot pushed a commit that referenced this issue Oct 18, 2024
PureWeen pushed a commit that referenced this issue Oct 18, 2024
- fixes #25199

Co-authored-by: Stephane Delcroix <stephane@delcroix.org>
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Oct 18, 2024
@tranb3r
Copy link
Author

tranb3r commented Nov 13, 2024

@StephaneDelcroix @PureWeen @simonrozsival
This is still happening with VS 17.12.0 GA and net9 GA.
Could you please double check? Thanks

@jamescrosswell
Copy link

I'm seeing something similar trying to AOT compile the MAUI sample from the Sentry repository.

@simonrozsival
Copy link
Member

simonrozsival commented Nov 25, 2024

@tranb3r I can repro the bug in .NET 9 GA. This should be fixed by #25420 already, but maybe it wasn't backported to GA and it will be release in the servicing release, PureWeen?

EDIT: I realized I was still building with RC2 because I didn't remove an override that forced the RC version: https://github.com/tranb3r/Issues/blob/main/MauiAppTestTrimAnalysis/Directory.Build.props#L5. After removing this override and changing global.json, I cannot reproduce the bug anymore. There is no more warning produced by ILLink. Sorry for the confusion.

@simonrozsival simonrozsival reopened this Nov 25, 2024
@github-project-automation github-project-automation bot moved this from Done to In Progress in MAUI SDK Ongoing Nov 25, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.10 platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

7 participants