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

[Trimming] Enable analyzers in Controls.Xaml #21927

Merged
merged 14 commits into from
May 3, 2024

Conversation

simonrozsival
Copy link
Member

@simonrozsival simonrozsival commented Apr 18, 2024

Description of Change

This PR enables analzyers in Controls.Xaml.csproj.

Almost all XAML runtime parsing code is marked with RUC and RDC. The TryGetPropertyName method was moved outside of ApplyPropertiesVisitor so that it can be called without producing a warning.

I introduced a new feature switch AreNonCompiledBindingsInXamlSupported and I'm thinking if it is the right way to go about it. I'm not very happy that it is necessary in BindingExtension.cs and I'm thinking if maybe we could transform BindingExtension into TypedBindingExtension in XamlC to split those two codepaths. This is the main reason why I'm opening this PR as a Draft for now. - EDIT: the feature switch wasn't needed after all

/cc @StephaneDelcroix

Issues Fixed

Contributes to #18658

@simonrozsival simonrozsival marked this pull request as ready for review April 23, 2024 14:18
@simonrozsival simonrozsival requested a review from a team as a code owner April 23, 2024 14:18
@@ -13,6 +14,7 @@ namespace Microsoft.Maui.Controls.Xaml
typeof(IValueConverterProvider),
typeof(IXmlLineInfoProvider),
typeof(IConverterOptions)])]
[RequiresUnreferencedCode("The OnIdiomExtension is not trim safe. Use OnIdiom<T> instead.")]
Copy link
Member Author

Choose a reason for hiding this comment

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

@jonathanpeppers this is the case I'm most worried about of these extensions. The {OnIdiom ...} cannot be simplified at compile time and I don't think we can really make it trimming-friendly because of Activator.CreateInstance(propertyType) which we call for value types.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if XamlC could transform OnIdiomExtension into OnIdiom<T> when it can infer T from the values passed to it 🤔 It might be worth trying.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think we could file an issue to fix {OnIdiom} in the future.

This PR makes good progress, so doesn't have to fix it here yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Issue: #22142

@Eilon Eilon added the area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions label Apr 30, 2024
@rmarinho rmarinho merged commit c3476e3 into dotnet:net9.0 May 3, 2024
48 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions fixed-in-9.0.0-preview.5.24307.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants