Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 24, 2025

This PR adds C# type forwarders to improve API compatibility between the Xamarin.AndroidX.SavedState and Xamarin.AndroidX.SavedState.SavedState.Android packages.

Changes Made

Created source/androidx.savedstate/savedstate/Additions/TypeForwarders.cs with type forwards for the following types from Xamarin.AndroidX.SavedState to Xamarin.AndroidX.SavedState.SavedState.Android:

  • AndroidX.SavedState.ISavedStateRegistryOwner
  • AndroidX.SavedState.SavedStateRegistry
  • AndroidX.SavedState.SavedStateRegistryController
  • AndroidX.SavedState.ViewTreeSavedStateRegistryOwner

Technical Details

The implementation follows the established pattern used in other AndroidX projects (such as androidx.lifecycle/lifecycle-viewmodel/Additions/TypeForwards.cs). The type forwarders use the System.Runtime.CompilerServices.TypeForwardedToAttribute to redirect type resolution from the savedstate assembly to the savedstate-android assembly where the actual implementations reside.

The project reference from savedstate to savedstate-android already exists in the generated project file, ensuring proper compilation and type resolution.

Verification

  • Both assemblies build successfully with no warnings or errors
  • TypeForwardedToAttribute metadata is correctly present in the generated assembly
  • Assembly sizes are appropriate (5.6KB for the forwarding assembly vs 85KB for the implementation assembly)
  • All four specified types are properly forwarded as confirmed by assembly metadata inspection

Fixes #1182.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…dX.SavedState.SavedState.Android

Co-authored-by: jonathanpeppers <[email protected]>
Copilot AI changed the title [WIP] Add typeforwards from Xamarin.AndroidX.SavedState to Xamarin.AndroidX.SavedState.SavedState.Android Add TypeForwarders from Xamarin.AndroidX.SavedState to Xamarin.AndroidX.SavedState.SavedState.Android Jun 24, 2025
Copilot AI requested a review from jonathanpeppers June 24, 2025 22:37
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspecting the binary, it looks correct:

image

The macOS lane timed out on CI, so we can ignore that.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 25, 2025 14:53
@jonathanpeppers jonathanpeppers merged commit 07d12d1 into main Jun 25, 2025
1 of 2 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-1182 branch June 25, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add typeforwards from Xamarin.AndroidX.SavedState to Xamarin.AndroidX.SavedState.SavedState.Android

2 participants