Skip to content

[tests] Move type map rewrite tests to net11 - #12736

Merged
simonrozsival merged 1 commit into
mainfrom
jonathanpeppers-fix-typemap-test-reference
Sep 9, 2026
Merged

[tests] Move type map rewrite tests to net11#12736
simonrozsival merged 1 commit into
mainfrom
jonathanpeppers-fix-typemap-test-reference

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

  • move the two JNI assembly rewriter tests that directly instantiate Microsoft.Android.Sdk.TrimmableTypeMap types from the net10.0 Xamarin.Android.Build.Tests assembly to the existing net11.0 trimmable type map integration test assembly
  • preserve the assertions that no XA4326 warning is emitted
  • restore compilation after [xabt] Move trimmable typemap tasks to net11 #12678 removed the transitive type map project reference from Xamarin.Android.Build.Tasks

This fixes the cross-platform compilation regression exposed by Azure DevOps build 1587962 without adding a net11.0 project reference to the net10.0 test project.

Validation

  • .\dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -v:minimal
  • .\dotnet-local.cmd test tests\Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests\Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests.csproj -v:minimal --filter "FullyQualifiedName~JniAssemblyRewriterTests" (2 passed)

Run the JNI rewriter cases that directly consume the trimmable type map generator in the existing net11 integration test assembly. This removes the accidental transitive reference from the net10 Xamarin.Android.Build.Tests project.

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

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 changes cleanly relocate the typemap-dependent tests to the net11 integration test project and preserve the warning assertions without introducing compile or behavioral issues in the remaining net10 test suite.

Pull request overview

Moves the two JNI assembly rewriter tests that depend on Microsoft.Android.Sdk.TrimmableTypeMap APIs out of the net10.0 Xamarin.Android.Build.Tests project into the existing net11 trimmable type map integration test project, restoring cross-platform compilation after the tasks/test refactoring in #12678 while preserving the “no XA4326 emitted” assertions.

Changes:

  • Added xUnit-based JniAssemblyRewriterTests to the Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests project to cover rewriting generated typemap images.
  • Extended the integration test MockBuildEngine to optionally capture BuildWarningEventArgs so tests can assert XA4326 is not logged.
  • Removed the typemap-generator-dependent tests (and the typemap using) from the Xamarin.Android.Build.Tests NUnit suite to eliminate the broken transitive dependency.
File summaries
File Description
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/MockBuildEngine.cs Allows capturing warning events for assertions via TaskLoggingHelper in integration tests.
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JniAssemblyRewriterTests.cs New xUnit tests validating typemap rewrite output and asserting XA4326 is not emitted.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/JniRemapping/JniAssemblyRewriterTests.cs Removes the two typemap-generator tests from the net10.0 test project to restore compilation.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Sep 8, 2026
@simonrozsival
simonrozsival merged commit 9f52486 into main Sep 9, 2026
45 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-fix-typemap-test-reference branch September 9, 2026 05:31
jonathanpeppers pushed a commit that referenced this pull request Sep 9, 2026
Remove the primary-constructor parameter list from the integration tests' `MockBuildEngine`, fixing CS0111 on `main`.

#12724 (`ecef743e91614754e6e1ab0ed7ed1834ecdedf5c`) added that signature after #12736 had introduced an explicit constructor with the same optional warning-list parameter. The merged combination left both constructors in place. This one-line repair keeps the explicit constructor and warning collection unchanged, including the existing no-XA4326 assertions; it does not change the production generator.

The failure appears in the Linux and macOS builds of [Azure DevOps build 1588988](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1588988):

    MockBuildEngine.cs(15,9): error CS0111: Type 'MockBuildEngine' already defines a member called 'MockBuildEngine' with the same parameter types.

Based directly on current `main` (`d907cd735615d5d17616cbba9e1a4aeef99ab61d`), independently of #12722. Rechecked live main and open PRs before editing and immediately before opening this PR; no equivalent fix was found.

### Validation

- Compiled the actual `MockBuildEngine.cs` using an isolated .NET SDK `11.0.100-rc.1.26431.118`, its net11.0 reference assemblies, and its real `Microsoft.Build.Framework.dll`. The same command reproduced CS0111 before the fix and succeeded without diagnostics after it.
- An artifacts-only host driver compiled together with the fixed source passed default construction, explicit `null`, and supplied-list cases. Logging with default/null was harmless; successive warnings appended to the supplied list with object identity preserved.
- The fixed file is byte-for-byte identical to its last working main version, immediately before #12724.

<details>
<summary>Direct compiler command</summary>

`SDK` points to the private SDK copy and `OUT` to the session artifact directory; run from the repository root:

```bash
refs=()
for ref in "$SDK"/packs/Microsoft.NETCore.App.Ref/*/ref/net11.0/*.dll; do
    refs+=("-r:$ref")
done
"$SDK/dotnet" exec \
    "$SDK/sdk/11.0.100-rc.1.26431.118/Roslyn/bincore/csc.dll" \
    -nologo -target:library -nullable:enable -langversion:latest \
    "-out:$OUT/MockBuildEngine.dll" "${refs[@]}" \
    "-r:$SDK/sdk/11.0.100-rc.1.26431.118/Microsoft.Build.Framework.dll" \
    tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/MockBuildEngine.cs
```

</details>

**Integration-test limit:** Attempted `dotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests.csproj --no-restore -p:BuildProjectReferences=false --filter 'FullyQualifiedName~JniAssemblyRewriterTests|FullyQualifiedName~GeneratedTypeMapRewriterTests' -v minimal`, but no tests executed in the unprepared worktree. A subsequent `dotnet build` of the same project with `--no-restore -p:BuildProjectReferences=false -v minimal` confirmed NETSDK1004 (missing `project.assets.json`). The local Android build outputs are also absent. No full bootstrap or device tests were run, and older installed generator binaries were not substituted for current-main integration validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

3 participants