[tests] verify trimmer warnings where appropriate#9076
Merged
jonathanpeppers merged 1 commit intodotnet:mainfrom Jul 4, 2024
Merged
[tests] verify trimmer warnings where appropriate#9076jonathanpeppers merged 1 commit intodotnet:mainfrom
jonathanpeppers merged 1 commit intodotnet:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
jonathanpeppers
commented
Jul 2, 2024
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
Member
|
@jonathanpeppers I repeated your test setup with a Here is the overview of the expected behaviour and property values (verified by inspecting binlogs and order of evaluation): Case: TrimMode=full, debug
Case: TrimMode=full, release
SuppressTrimAnalysisWarnings=false, debug
SuppressTrimAnalysisWarnings=false, release
IsAotCompatible=true, debug
IsAotCompatible=true, release
ConclusionThe added test in this PR does not seem to have correct expected values, please take a look at my notes above, and let me know if you have any questions. More importantly, the good news is, that the change in |
This comment was marked as outdated.
This comment was marked as outdated.
One change we need in the Android workload is to make sure that
trimmer warnings are displayed if a project sets `$(IsAotCompatible)`.
Customers would likely want this set for all platforms if they are
using NativeAOT on iOS or MacCatalyst.
I also wrote a test with somewhat complicated parameters to verify
we get warnings.
First, I can create a warning for both `IL2055` and `IL3050`:
// Member field
Type type = typeof (List<>);
// ...
// Later in OnCreate
Console.WriteLine (type.MakeGenericType (typeof (object)));
The combinations of tests are:
| Configuration | Property | Warning(s) |
| ------------- | ---------------------------------- | ----------------- |
| Debug | (defaults) | None |
| Release | (defaults) | None |
| Debug | TrimMode=full | None |
| Release | TrimMode=full | IL2055(2) |
| Release | SuppressTrimAnalysisWarnings=false | IL2055(2) |
| Debug | IsAotCompatible=true | IL2055, IL3050 |
| Release | IsAotCompatible=false | IL2055(2), IL3050 |
Some of the cases receive duplicate warnings, but this is expected as
the same behavior occurs in the simplest case:
* `dotnet new console`
* Add the above code to `Program.cs`
* `dotnet publish -c Release -r win-x64 -p:PublishAot=true`
* Receive warnings from both the Roslyn analyzer and ILC (NativeAOT compiler)
In a future PR, I might try to "fix" the duplicate warnings.
f03fa9c to
2b8a6fc
Compare
dellis1972
approved these changes
Jul 3, 2024
ivanpovazan
approved these changes
Jul 4, 2024
Member
ivanpovazan
left a comment
There was a problem hiding this comment.
LGTM, thanks for looking into this!
grendello
added a commit
that referenced
this pull request
Jul 5, 2024
* main: [tests] verify trimmer warnings where appropriate (#9076) Bump to jbevain/cecil@8c123e1 (#9078) [trimming] remove `$(NullabilityInfoContextSupport)` (#9069) [build] Bump `$(XABuildToolsVersion)`=35 (#9071) [ci] Move PR build to shared pool (#8854) Use AsyncTask from xamarin-android-tools (#9017) Bump to dotnet/sdk@02c06d398a 9.0.100-preview.7.24351.1 (#9067) [trimming] use public `$(MetricsSupport)` property (#9068) [ci] Update resourceManagement.yml (#9070) Bump to dotnet/android-api-docs@c14203771a (#8992) [trimming] remove `$(_AggressiveAttributeTrimming)` by default (#9062)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One change we need in the Android workload is to make sure that
trimmer warnings are displayed if a project sets
$(IsAotCompatible).Customers would likely want this set for all platforms if they are
using NativeAOT on iOS or MacCatalyst.
I also wrote a test with somewhat complicated parameters to verify
we get warnings.
First, I can create a warning for both
IL2055andIL3050:The combinations of tests are:
Some of the cases receive duplicate warnings, but this is expected as
the same behavior occurs in the simplest case:
dotnet new consoleProgram.csdotnet publish -c Release -r win-x64 -p:PublishAot=trueIn a future PR, I might try to "fix" the duplicate warnings.