Skip to content

[Java.Interop] Simplify single-backend binding generation - #13056

Merged
simonrozsival merged 1 commit into
mainfrom
simonrozsival-single-backend-bindings
Oct 10, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
simonrozsival-single-backend-bindings

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Follow-up for .NET 12 to #13030. With XAJavaInterop1 now the only supported backend, the binding generator no longer needs to carry a target through its symbol table or indirect generator construction.

Remove internal target storage/propagation, construct the generator directly, and remove its unused inheritance hooks. Keep the CLI selector, retired-target rejection, options validation, and public target-taking constructors; the compatibility constructors now forward to target-free overloads and are marked obsolete.

Collapse single-target test scaffolding without adding or removing existing test cases. Nullable and non-nullable baselines remain distinct, and all 192 generated files captured from the original suite remain byte-for-byte identical. Changes are confined to the binding generator and its tests.

Local validation

  • dotnet build external/Java.Interop/tools/generator/generator.csproj -v minimal — passed, 0 warnings/errors.
  • dotnet test external/Java.Interop/tests/generator-Tests/generator-Tests.csproj -v minimal — passed, 478/478, 0 skipped; same count as the pre-change baseline.
  • Generated-output SHA-256 comparison — passed for all 192 files, including NRT baselines. Direct CLI checks also confirmed identical default/explicit XA output and rejection of JavaInterop1.
  • make prepare && make all — preparation passed; the first build hit a bootstrap evaluation failure where compilation lacked generated ANDROID_* constants. Re-running unchanged make all compiled successfully, then reached the known missing API 37.1 reference-pack bootstrap requirement.
  • ./dotnet-local.sh build Microsoft.Android.slnx -t:BuildExtraApiLevels -c Debug -v quiet — passed.
  • ./dotnet-local.sh build build-tools/create-packs/Microsoft.Android.Sdk.proj -t:ConfigureLocalWorkload -c Debug -v quiet — passed.
  • Final make all — passed against this branch's own rebuilt SDK, without source/build-property workarounds.
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter 'FullyQualifiedName~BindingBuildTest&Name~DotNetBuildBinding|FullyQualifiedName~BindingBuildTest&Name~BindByteArrayInMethodParameter|FullyQualifiedName~BindingBuildTest&Name~NullableReferenceTypes|FullyQualifiedName~BindingBuildTest&Name~BindDefaultInterfaceMethods|FullyQualifiedName~BindingBuildTest&Name~BindingLibraryIncremental' — passed, 10/10, 0 skipped; CoreCLR and NativeAOT binding coverage.

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Remove internal target propagation and backend construction indirection
now that XAJavaInterop1 is the only supported binding generator backend.
Keep selector validation and obsolete target-taking constructors for
compatibility with tooling that references the generator assembly.

Collapse single-target test scaffolding while preserving the original
478-test suite and separate nullable-reference-type baselines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 22:29

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.

🟢 Approval recommended

The simplification is internally consistent and comprehensively validated, with only non-blocking compatibility-constructor test coverage suggested.

1 open finding
What changed in this PR

Simplifies Java.Interop binding generation now that XAJavaInterop1 is the sole backend.

Changes:

  • Removes target propagation and generator factory indirection.
  • Seals the generator and removes unused inheritance hooks.
  • Collapses single-backend test scaffolding while preserving compatibility constructors.
File Description
SymbolTable.cs Removes target storage; adds target-free construction.
ArraySymbol.cs Adds target-free construction.
InterfaceGen.cs Constructs the generator directly.
ClassGen.cs Constructs the generator directly.
JavaInteropCodeGenerator.cs Seals the implementation and removes virtual hooks.
CodeGenerationOptions.cs Removes the generator factory and target propagation.
UnmanagedCallersOnlyCallbackTests.cs Removes single-target setup.
SymbolTableTests.cs Uses target-free construction.
PeerMembersFieldTests.cs Removes redundant target configuration.
NRTJavaInteropCodeGeneratorTests.cs Removes redundant target override.
KotlinInlineClassEndToEndTests.cs Uses direct generator construction.
InterfaceConstantsTests.cs Flattens single-target fixture inheritance.
EnumGeneratorTests.cs Removes redundant target override.
DefaultInterfaceMethodsTests.cs Flattens single-target fixture inheritance.
CodeGeneratorTests.cs Consolidates the XA generator fixture.
CodeGeneratorTestBase.cs Removes target-dependent test infrastructure.
BlittableTypeTests.cs Removes redundant target override.
Compiler.cs Removes an unused target alias.
BaseGeneratorTest.cs Removes target parameters from integration scaffolding.

🧠 Review effort: Balanced

public void FindGenericTypes ()
{
var table = new SymbolTable (CodeGenerationTarget.XAJavaInterop1);
var table = new SymbolTable ();
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The complete correctness and integration review found no blocking regression. The sole-backend simplification preserves CLI defaults and retired-target rejection, retains the public constructors as warning-only forwarding overloads, and keeps the existing XA and nullable fixture/baseline paths intact.

@simonrozsival
simonrozsival merged commit bd0a6d6 into main Oct 10, 2026
43 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-single-backend-bindings branch October 10, 2026 05:50
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.

3 participants