-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Trimming] Enable analyzers in Controls.Xaml #21927
Conversation
This reverts commit 46ec439.
…nalyzers-controls-xaml
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
…ival/maui into enable-analyzers-controls-xaml
@@ -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.")] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: #22142
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 ofApplyPropertiesVisitor
so that it can be called without producing a warning.I introduced a new feature switch- EDIT: the feature switch wasn't needed after allAreNonCompiledBindingsInXamlSupported
and I'm thinking if it is the right way to go about it. I'm not very happy that it is necessary inBindingExtension.cs
and I'm thinking if maybe we could transformBindingExtension
intoTypedBindingExtension
in XamlC to split those two codepaths. This is the main reason why I'm opening this PR as a Draft for now./cc @StephaneDelcroix
Issues Fixed
Contributes to #18658