Skip to content

[MTP Integration Analysis] Duplicate TestingPlatformBuilderHook IDs are silently dropped #8435

@Evangelink

Description

@Evangelink

Summary

TestingPlatformSelfRegisteredExtensions silently deduplicates @(TestingPlatformBuilderHook) by ItemSpec and keeps the first item. If two hooks share the same ID but point to different extensions, one extension is dropped without any error or warning.

Evidence

  • src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/TestingPlatformAutoRegisteredExtensions.cs:98-100
    • // Distinct by ItemSpec and take the first one.
    • foreach (ITaskItem item in SelfRegisteredExtensionsBuilderHook.GroupBy(x => x.ItemSpec).Select(x => x.First()))
  • src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/TestingPlatformAutoRegisteredExtensions.cs:111
    • the generated log only reports the surviving item: Hook UID: '{item.ItemSpec}' ... TypeFullName: ...

Why this is a real issue

TestingPlatformBuilderHook IDs are supposed to be stable package identities. If two packages accidentally reuse the same ID, the build still succeeds but only the first extension is registered. That is a silent fallback path: the user gets a partially configured test app and no actionable MSBuild error telling them why one extension disappeared.

Suggested resolution

Fail the build when the same TestingPlatformBuilderHook ID appears with different metadata, and only deduplicate exact duplicates. Adding a focused acceptance/unit test for duplicate IDs would protect the registration pipeline from regressing back to first-wins behavior.

Related issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions