Skip to content

[Trimming] Disable assembly scanning for types implementing IVisual#20417

Merged
rmarinho merged 3 commits intodotnet:net9.0from
simonrozsival:feature-switch-ivisual-assembly-scanning
Feb 9, 2024
Merged

[Trimming] Disable assembly scanning for types implementing IVisual#20417
rmarinho merged 3 commits intodotnet:net9.0from
simonrozsival:feature-switch-ivisual-assembly-scanning

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Feb 7, 2024

Description of Change

When an app uses visuals, we preform assembly scanning to find all types that implement IVisual. This is not trimming-safe and it will likely not work with trimming/NativeAOT.

Instead, I propose adding a new app builder API UseVisual<TVisual>() to register any visual which is used in the app (alongside the default visuals). This API has been suggested in #4937.

For backwards compatibility, I added a feature switch MauiEnableIVisualAssemblyScanning which I propose to be disabled by default in .NET 9.

Issues Fixed

Fixes #4937, contributes to #19397

/cc @eerhardt @PureWeen

@simonrozsival simonrozsival force-pushed the feature-switch-ivisual-assembly-scanning branch 2 times, most recently from 60fcc52 to 7ee3a28 Compare February 7, 2024 18:20
@simonrozsival simonrozsival force-pushed the feature-switch-ivisual-assembly-scanning branch from 7ee3a28 to d8865d3 Compare February 8, 2024 16:54
@simonrozsival simonrozsival marked this pull request as ready for review February 8, 2024 17:11
@simonrozsival simonrozsival requested a review from a team as a code owner February 8, 2024 17:11
PureWeen
PureWeen previously approved these changes Feb 8, 2024
buildProps.Add("PublishAotUsingRuntimePack=true"); // TODO: This parameter will become obsolete https://github.com/dotnet/runtime/issues/87060
buildProps.Add("_IsPublishing=true"); // using dotnet build with -p:_IsPublishing=true enables targeting simulators
buildProps.Add($"RuntimeIdentifier={runtimeIdentifier}");
buildProps.Add("IlcTreatWarningsAsErrors=false"); // TODO: Remove this once all warnings are fixed https://github.com/dotnet/maui/issues/19397
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.

Thanks for fixing this!
I will create a separate PR for all IlcTreatWarningsAsErrors=false in net8.0 branch as a follow-up, as we might backport this feature to net8.0 on the dotnet/runtime side.

Copy link
Copy Markdown
Member

@ivanpovazan ivanpovazan left a comment

Choose a reason for hiding this comment

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

Test changes LGTM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants