dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

.aidl can produce C# NRT warnings #6686

Open jonathanpeppers opened 2 years ago

jonathanpeppers commented 2 years ago

This sample: https://github.com/xamarin/monodroid-samples/tree/dotnet/AIDLDemo

Produces build warnings:

obj\Debug\net6.0-android\aidl\IAdditionService.cs(38,27): warning CS8765: Nullability of type of parameter 'reply' doesn't match overridden member (possibly because of nullability attributes). 

Line is:

protected override bool OnTransact (int code, global::Android.OS.Parcel data, global::Android.OS.Parcel reply, int flags)
obj\Debug\net6.0-android\aidl\IAdditionService.cs(26,12): warning CS8603: Possible null reference return.
obj\Debug\net6.0-android\aidl\IAdditionService.cs(27,14): warning CS8600: Converting null literal or possible null value to non-nullable type.

Lines are:

public static Com.Xamarin.Aidldemo.IAdditionService AsInterface (global::Android.OS.IBinder obj)
{
    if (obj == null)
        return null;
jpobst commented 1 year ago

Related to https://github.com/xamarin/java.interop/pull/1052, we should probably mark these files as "auto-generated". As a side effect, Roslyn will disable NRT warnings in autogenerated files.