Skip to content

Conversation

@dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Aug 24, 2022

Fixes #7194
Context dotnet/maui#7038

The initial version of AndroidLinkResources commited in 9e6ce03 was to broad in its removal of Fields.
Certain field usage like Styleable arrays were not called using the ILstsfld op code. As a result they could
not be easily replaced with constant usage. However the linker removed ALL the fields from the Resource
sub classes. This would result in the following error

System.BadImageFormatException: 'Could not resolve field token 0x0400000b'.

This was because the int[] fields were removed as part of the linking process.

So to fix this we need to leave the int[] fields in the Resource subclasses and not remove them. We can
still remove all the other int fields though. We now also need to fix up the Resource subclass constructors
to replace the int field access with the constant values like we do for the rest of the app.
This was not required because because these constructors were removed. But now we have to keep them because
the static array initialisation takes place in these constructors.

@dellis1972 dellis1972 force-pushed the resourcelinkermk2 branch 3 times, most recently from 0c48b3e to 47741c8 Compare August 25, 2022 13:35
@dellis1972 dellis1972 force-pushed the resourcelinkermk2 branch 2 times, most recently from ffd25ed to 7065651 Compare September 5, 2022 12:03
@dellis1972 dellis1972 marked this pull request as ready for review September 7, 2022 09:57
@dellis1972 dellis1972 requested a review from jonpryor as a code owner September 7, 2022 09:57
@jonpryor jonpryor merged commit d521ac0 into dotnet:main Sep 13, 2022
@dellis1972 dellis1972 deleted the resourcelinkermk2 branch September 13, 2022 22:35
grendello added a commit to grendello/xamarin-android that referenced this pull request Sep 14, 2022
* main:
  [Xamarin.Android.Build.Tasks] Add AndroidPackagingOptionsExclude (dotnet#7356)
  [linker] preserve Java interfaces on non-bound Java types (dotnet#7204)
  [Xamarin.Android.Build.Tasks] AndroidLinkResources and Styleables (dotnet#7306)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make $(AndroidLinkResources) able to be the default for MAUI projects

3 participants