xamarin / AndroidX

AndroidX bindings for .NET for Android
MIT License
173 stars 42 forks source link

Add TypeForwards for `Xamarin.AndroidX.Collection`. #863

Closed jpobst closed 3 months ago

jpobst commented 3 months ago

Fixes: https://github.com/xamarin/AndroidX/issues/821 Fixes: https://github.com/xamarin/AndroidX/issues/807

In version 1.3.0, Google moved all the types in Xamarin.AndroidX.Collection to Xamarin.AndroidX.Collection.Jvm. While this is a source compatible change for users, it is not a binary compatible change for users that are relying on NuGets or assemblies that have not been recompiled.

These types will continue to work in Debug builds, but the linker and AOT compiler steps run for Release builds are unable to resolve the moved types, causing unfixable errors (other than recompiling all assemblies).

Adding [TypeForwardedToAttribute] attributes allows the linker and AOT to succeed without recompiling old assemblies.

Note this does not imply that we have tooling that can automatically detect these cases or that we will be proactive about adding type forwards, but we can manually add reported instances that are problematic like this one.