Skip to content

[build] Disable CoreCLR ReadyToRun without trimming - #12445

Open
jonathanpeppers wants to merge 4 commits into
mainfrom
jonathanpeppers-test-r2r-abstract-method-fix
Open

[build] Disable CoreCLR ReadyToRun without trimming#12445
jonathanpeppers wants to merge 4 commits into
mainfrom
jonathanpeppers-test-r2r-abstract-method-fix

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

  • disable CoreCLR ReadyToRun and composite ReadyToRun when trimming is disabled
  • emit XA0119 explaining that PublishTrimmed=true is required to use ReadyToRun
  • keep non-trimmed assemblies as IL so _LinkAssembliesNoShrink can safely apply FixAbstractMethodsStep
  • add coverage for the binding-assembly rewrite that previously failed with XALNS7015

Testing

  • Xamarin.Android.Build.Tests builds successfully
  • FixAbstractMethodsOnReadyToRunAssembly passes and asserts the XA0119 warning

Fixes: #11025

Add an enabled build test for the non-trimmed Release CoreCLR scenario where FixAbstractMethodsStep attempts to rewrite an R2R assembly and fails with XALNS7015.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 313238e1-f0ef-4218-b4ae-a124671f7881
Copilot AI lite review requested due to automatic review settings August 19, 2026 14:59

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.

Pull request overview

Adds/adjusts test coverage in Xamarin.Android.Build.Tests to reproduce the CoreCLR Release (non-trimmed) failure path where FixAbstractMethodsStep attempts to rewrite a ReadyToRun (R2R) assembly and Mono.Cecil cannot write mixed-mode assemblies, without changing product behavior.

Changes:

  • Removes the previously-ignored CoreCLR/non-trimmed variant of SimilarAndroidXAssemblyNames.
  • Adds a new focused test intended to exercise the CoreCLR Release + PublishTrimmed=false scenario that can trigger XALNS7015.

Disable CoreCLR ReadyToRun and composite R2R when trimming is off, and emit XA0119 to explain how to enable it. This keeps non-trimmed assemblies as IL so LinkAssembliesNoShrink can safely rewrite them.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 313238e1-f0ef-4218-b4ae-a124671f7881
@jonathanpeppers jonathanpeppers changed the title [tests] Reproduce CoreCLR R2R assembly rewrite failure [build] Disable CoreCLR ReadyToRun without trimming Aug 20, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer failed to deliver outputs. Please review the logs for details.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Generated by Android PR Reviewer for #12445

@github-actions github-actions Bot 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.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Generated by Android PR Reviewer for #12445 · gpt56 · 533.1 AIC · ⌖ 9.95 AIC · ⊞ 25.7K
Comment /review to run again

Comments that could not be inline-anchored

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets:10

🤖 ❌ MSBuild targets — MSBuild global properties are immutable unless explicitly listed in TreatAsLocalProperty, so this assignment cannot disable PublishReadyToRun when it came from -p:PublishReadyToRun=true; the assignment on the next line likewise cannot disable a globally supplied PublishReadyToRunComposite. With -p:PublishTrimmed=false -p:PublishReadyToRun=true, _AndroidReadyToRunWithoutTrimming becomes true, but PublishReadyToRun remains true, so crossgen2 still runs…

Documentation/docs-mobile/messages/xa0119.md:48

🤖 ⚠️ Documentation — The main PublishReadyToRun reference in Documentation/docs-mobile/building-apps/build-properties.md still says CoreCLR Release builds default this property to true and that composite R2R follows it, without mentioning the new PublishTrimmed=true prerequisite. Please update that public property documentation as part of this behavior change so users do not receive conflicting guidance.

Rule: Public behavior documentation

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets:21

🤖 ❌ MSBuild targets — This assignment cannot disable ReadyToRun when PublishReadyToRun was supplied as a global property (for example, dotnet publish -p:PublishReadyToRun=true -p:PublishTrimmed=false), because MSBuild global properties are immutable during project evaluation. In that common invocation the warning claims R2R was disabled, but crossgen2 still runs and the original mixed-mode rewrite failure remains. Please handle the global-property case (or fail it explicitly) and add a…

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 313238e1-f0ef-4218-b4ae-a124671f7881
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 313238e1-f0ef-4218-b4ae-a124671f7881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XALNS7015: Writing mixed-mode assemblies is not supported when FixAbstractMethodsStep patches an R2R-compiled Java binding assembly (CoreCLR, .NET 11)

2 participants