Skip to content

Avoid XALNS7015 by skipping FixAbstractMethods rewrites on ReadyToRun assemblies (CoreCLR/.NET 11) - #11205

Closed
simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-xalns7015-issue
Closed

simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-xalns7015-issue

Conversation

Copilot AI commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

CoreCLR is now the default on .NET 11 Android Release builds, and FixAbstractMethodsStep could attempt to rewrite R2R (mixed-mode) Java binding assemblies. That path throws System.NotSupportedException: Writing mixed-mode assemblies is not supported (XALNS7015) when Mono.Cecil writes the assembly.

  • Change: guard FixAbstractMethodsStep for R2R inputs

    • In FixAbstractMethodsStep.ProcessAssembly, detect ReadyToRun assemblies and skip abstract-method patching for those assemblies.
    • R2R detection is based on PE metadata (CorHeader.ManagedNativeHeaderDirectory.Size > 0).
    • Emits a debug log (once per assembly name) when skipping.
  • Change: re-enable previously suppressed coverage

    • Removed the temporary Assert.Ignore(...) for SimilarAndroidXAssemblyNames(..., AndroidRuntime.CoreCLR) so this scenario is exercised again instead of being silently skipped.
public void ProcessAssembly (AssemblyDefinition assembly, StepContext context)
{
	if (context.IsMainAssembly || !context.IsAndroidUserAssembly)
		return;

	if (IsReadyToRunAssembly (assembly))
		return;

	context.IsAssemblyModified |= FixAbstractMethods (assembly);
}

Copilot AI changed the title [WIP] Fix XALNS7015 error in .NET 11 build process Avoid XALNS7015 by skipping FixAbstractMethods rewrites on ReadyToRun assemblies (CoreCLR/.NET 11) Apr 24, 2026
Copilot AI requested a review from simonrozsival April 24, 2026 13:09
@simonrozsival

Copy link
Copy Markdown
Member

This is not the right fix - instead of skipping, we need to make sure the targets are in the right order

@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
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.

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

2 participants