-
Notifications
You must be signed in to change notification settings - Fork 528
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
[Xamarin.Android.Build.Tasks] downgrade d8/r8 warning
messages to info
#7643
Conversation
Fixes: dotnet/maui#10901 Building a .NET MAUI project such as: dotnet new maui dotnet build -c Release -f net6.0-android -p:AndroidLinkMode=r8 Results in build warnings from R8 such as: R8 : warning : Missing class androidx.window.extensions.WindowExtensions In 92bc705, we already had attempted to silence warnings from R8 such as: R8 : warning : Resource 'META-INF/MANIFEST.MF' already exists. At the time, there was no option to hide warnings, now there is! --map-diagnostics[:<type>] <from-level> <to-level> # Map diagnostics of <type> (default any) reported as # <from-level> to <to-level> where <from-level> and # <to-level> are one of 'info', 'warning', or 'error' and the # optional <type> is either the simple or fully qualified # Java type name of a diagnostic. If <type> is unspecified, # all diagnostics at <from-level> will be mapped. # Note that fatal compiler errors cannot be mapped. We can pass: --map-diagnostics warning info Which can be done in existing apps via: <AndroidD8ExtraArguments>--map-diagnostics warning info</AndroidD8ExtraArguments> <AndroidR8ExtraArguments>--map-diagnostics warning info</AndroidR8ExtraArguments> To solve this problem, let's create a new `$(AndroidD8IgnoreWarnings)` MSBuild property and make use of one we already have `$(AndroidR8IgnoreWarnings)`: <ItemGroup> <_AndroidD8MapDiagnostics Condition=" '$(AndroidD8IgnoreWarnings)' == 'true' " Include="warning" To="info" /> <_AndroidR8MapDiagnostics Condition=" '$(AndroidR8IgnoreWarnings)' == 'true' " Include="warning" To="info" /> </ItemGroup> We can then use these item groups to pass `--map-diagnostics` as appropriate. Developers can turn off either property to disable this behavior. We can then remove the weird `Regex` code added in 92bc705. The existing tests from 92bc705 should also be sufficient for testing this change.
warning
messages to info
warning
messages to info
The one test failure looks unrelated:
|
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.
Do we have a unit test which convers this to make sure the warnings are mapped to info?
The test from 92bc705, it previously had build warnings like this when enabling multi-dex:
It asserts there are 0 warnings: https://github.com/xamarin/xamarin-android/blob/d4c2a5e2ba148ea1d63fdc7f8c984642e7b5b369/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs#L282 Now it should log a message instead:
|
* main: [Xamarin.Android.Build.Tasks] skip XA1034 logic in some cases (dotnet#7680) [ci] Move OneLocBuild task to scheduled pipeline (dotnet#7679) [Mono.Android] ServerCertificateValidationCallback() and redirects (dotnet#7662) Bump to xamarin/Java.Interop/main@cf80deb7 (dotnet#7664) Localized file check-in by OneLocBuild (dotnet#7668) [api-merge] Correctly compute //method/@deprecated-since (dotnet#7645) [Xamarin.Android.Build.Tasks] _Microsoft.Android.Resource.Designer (dotnet#6427) [Xamarin.Android.Build.Tasks] downgrade d8/r8 `warning` messages to `info` (dotnet#7643) [Xamarin.Android.Build.Tasks] fix cases of missing `@(Reference)` (dotnet#7642) [Xamarin.Android.Build.Tasks] delay ToJniName calls in ManifestDocument (dotnet#7653) [Xamarin.Android.Build.Tasks] fast path for `<CheckClientHandlerType/>` (dotnet#7652)
Fixes: dotnet/maui#10901
Building a .NET MAUI project such as:
Results in build warnings from R8 such as:
In 92bc705, we already had attempted to silence warnings from R8 such as:
At the time, there was no option to hide warnings, now there is!
We can pass:
Which can be done in existing apps via:
To solve this problem, let's create a new
$(AndroidD8IgnoreWarnings)
MSBuild property and make use of one we already have$(AndroidR8IgnoreWarnings)
:We can then use these item groups to pass
--map-diagnostics
as appropriate. Developers can turn off either property to disable this behavior.We can then remove the weird
Regex
code added in 92bc705. The existing tests from 92bc705 should also be sufficient for testing this change.Now r8 emits:
And you don't get an MSBuild warning anymore.