Skip to content

Regression: incorrect nullability annotations in Xamarin.AndroidX.AppCompat 1.8.0 #1558

Open

Description

@Bip901

Android framework version

net10.0-android

Affected platform version

.NET 10.0.400

Description

Xamarin.AndroidX.AppCompat used to have correct C# nullability annotations in version 1.7.1.4, but they're gone in version 1.8.0, resulting in numerous build warnings.

This is not an isolated incident; A similar regression exists for the latest version of AndroidX.Fragment.App (e.g. in Fragment.GetString). My guess is the nullable annotations are not being properly bound from Java.

Steps to Reproduce

  1. Create a project:
dotnet new androidlib
dotnet package add '[email protected]'
  1. Add the following code:
public class Class1
{
    public void X()
    {
        AndroidX.AppCompat.App.AlertDialog dialog = new AndroidX.AppCompat.App.AlertDialog.Builder(null!).Create();
        //  Code is valid because the return value of Create() is non-null
    }
}
  1. dotnet build and observe the build warnings:
Class1.cs(9,53): warning CS8600: Converting null literal or possible null value to non-nullable type.
  1. Downgrade to 1.7.1.4 and observe the warnings are gone

Did you find any workaround?

No response

Relevant log output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions