[build] Error on marshal methods with ReadyToRun - #12613
Open
simonrozsival wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets — 💡 In this target the surrounding boolean comparisons use And and True (e.g., the… |
|
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs — 💡 This regression test asserts the new XA1049 is reported, but it doesn’t verify the build fails… |
What changed in this PR
Adds an early, user-facing diagnostic for an unsupported build configuration in .NET for Android: enabling marshal methods rewriting together with ReadyToRun. This prevents a later-stage implementation error from the marshal-methods rewriter and documents the incompatibility in the error-code reference.
Changes:
- Introduces
XA1049validation in the MSBuild targets whenAndroidEnableMarshalMethodsandPublishReadyToRunare bothtrue. - Adds a new build test covering the failure mode.
- Adds localized resource text and updates documentation (TOC, error index, build properties, and new
xa1049.mdpage).
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Adds the XA1049 early-fail MSBuild validation. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs | Adds a regression test asserting the new error is emitted. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Adds the localized message text for XA1049. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Updates the generated accessor for the new XA1049 resource entry. |
| Documentation/docs-mobile/TOC.yml | Adds the new XA1049 doc page to the TOC. |
| Documentation/docs-mobile/messages/xa1049.md | New documentation page for XA1049. |
| Documentation/docs-mobile/messages/index.md | Adds XA1049 to the error code index. |
| Documentation/docs-mobile/building-apps/build-properties.md | Documents the AndroidEnableMarshalMethods / PublishReadyToRun incompatibility. |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Description
Fail early with
XA1049whenAndroidEnableMarshalMethodsandPublishReadyToRunare both enabled.Without this validation, ReadyToRun compilation completes before the marshal-methods rewriter attempts to modify the mixed-mode assemblies and fails with the implementation-level error
XARMM7015: Writing mixed-mode assemblies is not supported.This also documents the incompatibility and adds the new diagnostic to the error-code reference.
Testing
AndroidEnableMarshalMethodsWithReadyToRunFailsBuildBasicApplicationPublishReadyToRun(all four composite/RID cases)