AndroidLinkResources and Styleables #7306
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 couldnot 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 theResource
subclasses and not remove them. We canstill remove all the other
int
fields though. We now also need to fix up theResource
subclass constructorsto 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.