Skip to content

Add AOT Compatibility#1820

Merged
TheCodeTraveler merged 24 commits into
CommunityToolkit:mainfrom
simonrozsival:mark-relevant-assemblies-aot-compatible
Sep 7, 2024
Merged

Add AOT Compatibility#1820
TheCodeTraveler merged 24 commits into
CommunityToolkit:mainfrom
simonrozsival:mark-relevant-assemblies-aot-compatible

Conversation

@simonrozsival
Copy link
Copy Markdown
Contributor

@simonrozsival simonrozsival commented Apr 16, 2024

Description of Change

This PR marks all product assemblies as AOT-compatible and fixes all warnings produced by trim and AOT analyzers. The list of warnings was surprisingly short:

  • BaseBehavior.IsBound is inherently trim-unsafe, but since it's already [Obsolete], I think it is OK to just mark it as [RequiresUnreferencedCode] (any app or library which would call this method will get a trimming warning and will have to deal with it)
  • ServiceCollectionExtensions methods need [DynamicallyAccessedMembers] attributes matching IServiceCollection
  • PopupService.AddTransientPopup needs [DynamicallyAccessedMembers] attributes matching IServiceCollection
  • ValueConverterExtension.IsValidTargetType is the most complicated case I think. It is not possible to fix this case with [DAM] attributes because as I propagated the attribute to all callsites, I reached a point where I would need to add the attribute to Microsoft.Maui.Controls.IValueConverter which wasn't possible. I tried to simplify the method, because it seemed too complicated. I'll leave some comments in the code to explain my reasoning.

TODO (incomplete list)

  • Fix Windows specific warnings (PopupExtensions.SetColor, JSON deserialization in MapHandler
  • Remove all uses of new Binding(...) in favor of expression-based bindings (not available yet, still WIP in MAUI)
  • Update type converters of types which define implicit operators (FileMediaSource, MediaSource, ResourceMediaSource, UriMediaSource)

Linked Issues

PR Checklist

Additional information

@simonrozsival simonrozsival force-pushed the mark-relevant-assemblies-aot-compatible branch from 0eab567 to 857ba9a Compare April 16, 2024 19:37
Comment thread src/CommunityToolkit.Maui/Extensions/ValueConverterExtension.shared.cs Outdated
@TheCodeTraveler TheCodeTraveler self-assigned this Apr 27, 2024
@dotnet-policy-service dotnet-policy-service Bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels May 28, 2024
@TheCodeTraveler TheCodeTraveler removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days labels Jun 6, 2024
@dotnet-policy-service dotnet-policy-service Bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels Jul 6, 2024
@TheCodeTraveler TheCodeTraveler added needs discussion Discuss it on the next Monthly standup and removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days labels Sep 5, 2024
@TheCodeTraveler TheCodeTraveler marked this pull request as ready for review September 5, 2024 18:35
@TheCodeTraveler TheCodeTraveler changed the title Mark product assemblies as AOT compatible Add AOT Compatibility Sep 5, 2024
@TheCodeTraveler TheCodeTraveler removed the needs discussion Discuss it on the next Monthly standup label Sep 7, 2024
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started @simonrozsival!

I confirmed our Sample App runs on iOS when <PublishAOT>enabled</PublishAOT> with no problems.

@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) September 7, 2024 19:46
@TheCodeTraveler TheCodeTraveler merged commit 725dd41 into CommunityToolkit:main Sep 7, 2024
@simonrozsival
Copy link
Copy Markdown
Contributor Author

@brminnick thanks a lot for finishing the PR!

@TheCodeTraveler TheCodeTraveler mentioned this pull request Sep 19, 2024
6 tasks
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Add Support for NativeAOT

2 participants