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

[XC] Avoid NativeAOT trim warnings for compiled bindings #25420

Conversation

simonrozsival
Copy link
Member

Contributes to #25406

Description of Change

The BindingExtension class has an attribute that tells XamlC to include the XamlTypeResovler in the service provider when calling the ProvideValue method:

[RequireService([typeof(IXamlTypeResolver), typeof(IXamlDataTypeProvider)])]
public sealed class BindingExtension : IMarkupExtension<BindingBase>

The XamlTypeResovler is not trim and AOT compatible. Fortunately, it is NOT necessary when the binding is compiled. This PR adds a workaround that will prevent generating the faulty code in .NET 9. I think we should follow-up on this later in .NET 10 and properly compile the BindingExtension (see the referenced issue for more details).

@simonrozsival simonrozsival added the area-xaml XAML, CSS, Triggers, Behaviors label Oct 21, 2024
@simonrozsival simonrozsival added this to the .NET 9.0 GA milestone Oct 21, 2024
@simonrozsival simonrozsival requested a review from a team as a code owner October 21, 2024 14:25
@simonrozsival simonrozsival requested review from StephaneDelcroix and removed request for a team October 21, 2024 14:25
@@ -151,6 +151,8 @@ public class XamlCTask : XamlTask
/// </summary>
public bool ValidateOnly { get; set; }

internal bool GenerateFullILInValidateOnlyMode { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we shouldn't have a need to ever set this from MSBuild? Just unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly.

@rmarinho rmarinho merged commit 1ad1f6a into release/9.0.1xx Oct 21, 2024
7 checks passed
@rmarinho rmarinho deleted the dev/srozsival/fix-compiled-binding-extension-ilc-warning branch October 21, 2024 18:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-9.0.0
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants