-
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 trimming and AOT analyzers in Core #21076
Conversation
[RequiresDynamicCode("The GetImageSourceServiceType method is not AOT compatible. Use GetImageSourceService instead.")] | ||
[RequiresUnreferencedCode("The GetImageSourceServiceType method is not trimming compatible. Use GetImageSourceService 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.
Just for future reference:
We've been burned in other projects by adding RUC (and other annotations) onto interface members. The problem is that doing so effectively marks all implementations of the interface with RUC. But RUC is a statement about the implementation, not about the interface.
For example Type.GetMembers - this has some annotation on it, but it's an abstract class. The reflection based implementation needs that annotation, but we also have MetadataLoadContext
which also implements Type
and that one doesn't need the annotation. But there's no way to tell that to the system and it will produce warnings and so on. Not that we will change Type.GetMembers, but it shows how the statement applies to all implementations, regardless if they are affected or not. (and also, removing the annotation from the interface member is a breaking change!)
I guess in this specific case, we basically don't care, since the methods are obsolete anyway. But it's a good rule to remember for the future: "Think hard if the annotation should be on the interface, really hard!"
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 struggled with this one. It feels wrong adding those attributes to the interface. I just couldn't figure out how else to apply the annotation in this case. I arrived at the same conclusion that we don't care too much since we already marked it obsolte and we don't know about any customer who would have their custom implementation of IImageSourceProvider at the moment.
The analyzers reported the following issues on Windows:
We could do something about |
My "hope" is we would soon be able to put something like this in the project template: <!-- greenfield apps should have an easier time with this -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TrimMode>full</TrimMode>
</PropertyGroup> Then in the iOS/Android workloads, we would do similar for the iOS/Android templates there. But if we do this in MAUI, will there be trimming warnings from the WindowsAppSDK we can't do much about? |
I asked and apparently they're aware of it, and hopefully will fix it soon. |
I have sent WindowsAppSdk PRs in the past, and that seemed to move things along more quickly. So, if the changes are simple, we can consider that. |
src/Compatibility/Core/src/Windows/FrameworkElementExtensions.cs
Outdated
Show resolved
Hide resolved
d94ff48
to
4982f75
Compare
5c82f23
to
b4aa065
Compare
The failing test seems unrelated |
Description of Change
This PR marks the
Core
project as AOT-compatible and it fixes all the warnings reported by the analyzers which are now enabled.Issues Fixed
Contributes to #18658
/cc @jonathanpeppers @vitek-karas