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

[Java.Interop] ignore remaining trimming warnings #1190

Merged
merged 11 commits into from
Feb 14, 2024

Commits on Feb 13, 2024

  1. [Java.Interop] ignore remaining trimming warnings

    Fixes: dotnet#1157
    
    The remaining trimmer warnings are around usage of System.Reflection
    such as:
    
    * Create an `Invoker` type from an original type via
      `Type.Assembly.GetType()`
    
    * Create a `Type` based on a `ParameterInfo.ParameterType` and/or
      create instances
    
    * Use `Type.MakeGenericType()`
    
    * Use `Type.MakeArrayType()`
    
    The trimming warnings themselves all indicate that these types "might
    be trimmed", in that nothing explicitly preserves them. However, we
    have a plethora of custom trimmer steps that work to preserve these
    types involved in Java interop, such as:
    
    * https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
    * https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs
    * https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs
    * https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Sdk.ILLink/PreserveJavaInterfaces.cs
    * https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Sdk.ILLink/PreserveRegistrations.cs
    
    One day, in a perfect world, we could remove these trimmer steps and
    completely rely on the trimmer's warnings & attributing mechanisms.
    That day doesn't have to be today -- as our goal is begin surfacing
    trimmer warnings to users in their own code and dependencies.
    
    With these warnings ignored, we can fully enable analyzers with:
    
        <IsTrimmable>true</IsTrimmable>
        <EnableAotAnalyzer>true</EnableAotAnalyzer>
    
    We can then remove:
    
        [assembly: AssemblyMetadata ("IsTrimmable", "True")]
    
    As the MSBuild property does this for us, in addition to enabling
    analyzers.
    
    I don't think we should enable `$(IsAotCompatible)` quite yet, as
    `Java.Interop.dll` likely *won't work* yet on NativeAOT, and this
    places metadata that says an assembly is supported. We should just use
    the `$(EnableAotAnalyzer)` analyzers for now, so we don't introduce
    new issues.
    jonathanpeppers committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    7482f46 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    33bd501 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4522d35 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9c7a05a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5300682 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    502e852 View commit details
    Browse the repository at this point in the history
  7. Formatting

    jonathanpeppers committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    a493d15 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ea2ff53 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ad5019d View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2024

  1. Formatting

    jonathanpeppers committed Feb 14, 2024
    Configuration menu
    Copy the full SHA
    f6bb010 View commit details
    Browse the repository at this point in the history
  2. Extra newline

    jonathanpeppers committed Feb 14, 2024
    Configuration menu
    Copy the full SHA
    aea690e View commit details
    Browse the repository at this point in the history