Skip to content

Fail on conflicting TestingPlatformBuilderHook IDs#8508

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/mtp-integration-analysis-fix-duplicate-ids
Open

Fail on conflicting TestingPlatformBuilderHook IDs#8508
Copilot wants to merge 3 commits into
mainfrom
copilot/mtp-integration-analysis-fix-duplicate-ids

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

TestingPlatformSelfRegisteredExtensions previously collapsed duplicate TestingPlatformBuilderHook items by ID and kept the first entry. If two packages reused an ID with different metadata, one extension disappeared silently.

  • Duplicate validation

    • Detects duplicate hook IDs with conflicting DisplayName or TypeFullName.
    • Logs an MSBuild error instead of generating a partially registered test app.
  • Exact duplicate handling

    • Keeps deduplication for truly identical hook entries.
    • Generates registration code from the validated, deduplicated hook set.
  • Regression coverage

    • Adds unit coverage for exact duplicate deduplication.
    • Adds unit coverage for conflicting duplicate IDs failing generation.
<TestingPlatformBuilderHook Include="hook">
  <DisplayName>First</DisplayName>
  <TypeFullName>Contoso.FirstHook</TypeFullName>
</TestingPlatformBuilderHook>

<TestingPlatformBuilderHook Include="hook">
  <DisplayName>Second</DisplayName>
  <TypeFullName>Contoso.SecondHook</TypeFullName>
</TestingPlatformBuilderHook>

The above now fails the build instead of silently registering only the first hook.

Copilot AI self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 16:01
Copilot AI review requested due to automatic review settings May 22, 2026 16:01
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 22, 2026 16:09
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 22, 2026 16:11
Copilot AI changed the title [WIP] Fix silent dropping of duplicate TestingPlatformBuilderHook IDs Fail on conflicting TestingPlatformBuilderHook IDs May 22, 2026
Copilot AI requested a review from Evangelink May 22, 2026 16:11
@Evangelink Evangelink marked this pull request as ready for review May 23, 2026 15:49
Copilot AI review requested due to automatic review settings May 23, 2026 15:49
@Evangelink
Copy link
Copy Markdown
Member

/review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens TestingPlatformSelfRegisteredExtensions (MSBuild task) by validating TestingPlatformBuilderHook items for duplicate IDs: exact duplicates are deduplicated, while conflicting duplicates now fail the build to avoid silently dropping an extension.

Changes:

  • Added validation + deduplication for SelfRegisteredExtensionsBuilderHook items, failing on conflicting metadata for the same Include/ID.
  • Updated code generation to use the validated, deduplicated hook set.
  • Added unit tests covering exact-duplicate deduplication and conflicting-duplicate failure behavior.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.MSBuild.UnitTests/MSBuildTests.cs Adds unit coverage for deduplication and for build failure when duplicate hook IDs have conflicting metadata.
src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/TestingPlatformAutoRegisteredExtensions.cs Implements hook validation/deduplication and wires code generation to the validated hook list.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Assert.IsTrue(selfRegisteredExtensions.Execute());

string generatedSource = inMemoryFileSystem.Files["obj/selfRegisteredExtensionsFile"]!;
Assert.HasCount(1, Regex.Matches(generatedSource, "global::Contoso.Hook.AddExtensions"));
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.

[MTP Integration Analysis] Duplicate TestingPlatformBuilderHook IDs are silently dropped

3 participants