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

[Xamarin.Android.Build.Tasks] downgrade d8/r8 warning messages to info #7643

Merged
merged 2 commits into from
Jan 4, 2023

Commits on Dec 15, 2022

  1. [Xamarin.Android.Build.Tasks] downgrade warning messages to info

    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.
    jonathanpeppers committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    2ac0310 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2023

  1. Better link for r8

    jonathanpeppers authored Jan 3, 2023
    Configuration menu
    Copy the full SHA
    947c732 View commit details
    Browse the repository at this point in the history