Skip to content

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

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-xalns7015-issue
Draft

Avoid XALNS7015 by skipping FixAbstractMethods rewrites on ReadyToRun assemblies (CoreCLR/.NET 11)#11205
Copilot wants to merge 2 commits intomainfrom
copilot/fix-xalns7015-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

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);
}

…sion test

Agent-Logs-Url: https://github.com/dotnet/android/sessions/86d7cd7c-6cdd-4bf1-80cb-c3f4af737ce1

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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