Skip to content

Add TypeForwards for Xamarin.AndroidX.Collection. #863

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

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Mar 14, 2024

Fixes: #821
Fixes: #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.

@jpobst jpobst marked this pull request as ready for review March 14, 2024 21:17
@jpobst jpobst requested a review from moljac March 14, 2024 21:17
@jpobst jpobst merged commit 8338217 into main Mar 15, 2024
@jpobst jpobst deleted the collection-typeforwards branch March 15, 2024 17:24
jpobst added a commit that referenced this pull request Jun 27, 2024
Context: #863
Fixes: dotnet/android#9049
Fixes: #909

In version `2.8.*`, Google moved all the types in 2 libraries into 2 new libraries:
- `Xamarin.AndroidX.Lifecycle.Common` to `Xamarin.AndroidX.Lifecycle.Common.Jvm`.  
- `Xamarin.AndroidX.Lifecycle.ViewModel` to `Xamarin.AndroidX.Lifecycle.ViewModel.Android`.  

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 may 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants