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

More trimming fixes, enable analyzers unconditionally #15815

Merged
merged 6 commits into from
Jun 5, 2024

Conversation

maxkatz6
Copy link
Member

What does the pull request do?

After that PR simple Avalonia Hello World produces 0 trimming related warnings/errors in AOT mode.
Note, even before this PR all of these warnings were false positives, without actual runtime errors. But it's always nicer to avoid warnings.

What was changed in this PR:

  1. Avoid #pragma warning disable , when UnconditionalSuppressMessage should be used. Otherwise suppressions won't be respected in NAOT compilation.
  2. Don't instantiate ReflectionMethodAccessorPlugin at all, when dynamic code isn't enabled.
  3. Suppress Expression.OperatorName warnings, as this method is only used in design time.
  4. Fix missing attribute on WinRTInspectable.

TODO:
Not related to warnings, but we can improve output binary size by respecting IsDynamicCodeSupported property in more places. But even better to wait until feature switches in .NET 9, so whole reflection bindings related codebase can be disabled and trimmed out.

We also should start running some tests with AOT enabled. MSTest might be required to do so, since xUnit doesn't support AOT yet.

Fixed issues

Fixes #13897
Fixes #11727

@maxkatz6 maxkatz6 added bug area-trimming-aot backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels May 26, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0048618-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Jun 5, 2024
Merged via the queue into master with commit e7b196c Jun 5, 2024
12 checks passed
@maxkatz6 maxkatz6 deleted the more-trimming-fixes branch June 5, 2024 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-trimming-aot backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IL2026 & 2104 Trim Warnings Trim warnings for ObservableStreamPlugin etc
3 participants