Skip to content

[tests] Fix duplicate MockBuildEngine constructor - #12741

Merged
jonathanpeppers merged 1 commit into
mainfrom
simonrozsival-fix-duplicate-constructor
Sep 9, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
simonrozsival-fix-duplicate-constructor

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

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:

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 [typemap] Reduce generator allocations with modern .NET APIs #12724.
Direct compiler command

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

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

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.

PR #12724 added a primary constructor after #12736 introduced the same
explicit warning-collecting constructor, causing CS0111 on main.

Remove only the primary-constructor parameter list.  Keep the explicit
constructor and warning collection used by the JNI rewrite tests.

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

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.

Copilot review overview

🟢 Approval recommended

The change is minimal, directly addresses the reported CS0111 duplicate-constructor error, and preserves existing test helper behavior.

Review tier: Lite
Findings: None

What changed in this PR

Fixes a compilation regression in the Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests test project by removing the unintended primary-constructor parameter list from MockBuildEngine, avoiding the duplicate-constructor CS0111 error while preserving the existing explicit constructor behavior.

Changes:

  • Remove the primary-constructor parameter list from MockBuildEngine so only the explicit constructor remains.
  • Keep the warning collection behavior and optional warnings list parameter unchanged.
File Description
tests/​Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/​MockBuildEngine.cs Removes the primary constructor signature to eliminate the duplicate-constructor compile error in integration tests.

@jonathanpeppers
jonathanpeppers merged commit c6cf656 into main Sep 9, 2026
7 of 43 checks passed
@jonathanpeppers
jonathanpeppers deleted the simonrozsival-fix-duplicate-constructor branch September 9, 2026 14:16
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