Skip to content

[build] Error on marshal methods with ReadyToRun - #12613

Open
simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-marshal-methods-r2r-error
Open

[build] Error on marshal methods with ReadyToRun#12613
simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-marshal-methods-r2r-error

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Description

Fail early with XA1049 when AndroidEnableMarshalMethods and PublishReadyToRun are 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

  • AndroidEnableMarshalMethodsWithReadyToRunFailsBuild
  • BasicApplicationPublishReadyToRun (all four composite/RID cases)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 1, 2026 04:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Review tier: Lite
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets — 💡 In this target the surrounding boolean comparisons use And and True (e.g., the…
Medium severity 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 XA1049 validation in the MSBuild targets when AndroidEnableMarshalMethods and PublishReadyToRun are both true.
  • Adds a new build test covering the failure mode.
  • Adds localized resource text and updates documentation (TOC, error index, build properties, and new xa1049.md page).
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

Comment thread src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants