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] suppress one instance of IL2072 #1205

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

jonathanpeppers
Copy link
Member

Context: dotnet/android#8805

When testing new defaults for TrimMode=full in xamarin/xamarin-android:

dotnet new android
dotnet build -c Release -r android-arm64

Results in a single warning:

external\Java.Interop\src\Java.Interop\Java.Interop\JniRuntime.JniValueManager.cs(890,4): Trim analysis warning IL2072: Java.Interop.ProxyValueMarshaler.CreateGenericObjectReferenceArgumentState(Object, ParameterAttributes): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler(Type)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

This appears to be a case where the trimmer (ILLink's analyzers) can detect a problem where the Roslyn analyzer could not. It is generally possible for the trimmer to discover some new warning, as it has a complete view of the final code.

This appears to be similar to some other places we used the justification:

[UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "This code path is not used in Android projects.")]

Context: dotnet/android#8805

When testing new defaults for `TrimMode=full` in xamarin/xamarin-android:

    dotnet new android
    dotnet build -c Release -r android-arm64

Results in a single warning:

    external\Java.Interop\src\Java.Interop\Java.Interop\JniRuntime.JniValueManager.cs(890,4): Trim analysis warning IL2072: Java.Interop.ProxyValueMarshaler.CreateGenericObjectReferenceArgumentState(Object, ParameterAttributes): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler(Type)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

This appears to be a case where the trimmer (ILLink's analyzers) can
detect a problem where the Roslyn analyzer could not. It is generally
possible for the trimmer to discover some new warning, as it has a
complete view of the final code.

This appears to be similar to some other places we used the justification:

    [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "This code path is not used in Android projects.")]
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this pull request Mar 13, 2024
@jonathanpeppers jonathanpeppers changed the title [Java.Interop] supress one instance of IL2072 [Java.Interop] suppress one instance of IL2072 Mar 13, 2024
@jonpryor jonpryor merged commit 651de42 into main Mar 13, 2024
4 checks passed
@jonpryor jonpryor deleted the CreateGenericObjectReferenceArgumentState branch March 13, 2024 15:19
jonpryor pushed a commit to dotnet/android that referenced this pull request Mar 14, 2024
Changes: dotnet/java-interop@5bca8ad...651de42

  * dotnet/java-interop@651de427: [Java.Interop] supress one instance of IL2072 (dotnet/java-interop#1205)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants