Skip to content

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

Merged
rmarinho merged 4 commits into
release/9.0.1xxfrom
dev/srozsival/fix-compiled-binding-extension-ilc-warning
Oct 21, 2024
Merged

[XC] Avoid NativeAOT trim warnings for compiled bindings#25420
rmarinho merged 4 commits into
release/9.0.1xxfrom
dev/srozsival/fix-compiled-binding-extension-ilc-warning

Conversation

@simonrozsival

Copy link
Copy Markdown
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
/// </summary>
public bool ValidateOnly { get; set; }

internal bool GenerateFullILInValidateOnlyMode { get; set; }

Copy link
Copy Markdown
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
Copy Markdown
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
@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