Skip to content

Document TestingPlatformBuilderHook auto-registration for MTP extension authors#54122

Open
Evangelink wants to merge 2 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/mtp-testingplatformbuilderhook
Open

Document TestingPlatformBuilderHook auto-registration for MTP extension authors#54122
Evangelink wants to merge 2 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/mtp-testingplatformbuilderhook

Conversation

@Evangelink
Copy link
Copy Markdown
Member

@Evangelink Evangelink commented Jun 2, 2026

Addresses microsoft/testfx#5552 by documenting the TestingPlatformBuilderHook auto-registration mechanism for Microsoft.Testing.Platform (MTP) extension authors.

What changed

Adds a new ## Auto-register your extension with TestingPlatformBuilderHook section to docs/core/testing/microsoft-testing-platform-architecture-extensions.md that explains:

  • Create the hook class – the required public static class TestingPlatformBuilderHook with the AddExtensions(ITestApplicationBuilder, string[]) signature, including a sample mirroring how in-box extensions like Microsoft.Testing.Extensions.Retry ship.
  • Declare the MSBuild item – the buildMultiTargeting/<PackageId>.props file that declares a <TestingPlatformBuilderHook> item with Include, DisplayName, and TypeFullName metadata.
  • The Include GUID is a random identifier – an explicit subsection clarifying that this GUID is not the same as IExtension.Uid, that it must be freshly generated for every new extension, and (with an [!IMPORTANT] callout) that copying a GUID from another extension causes the hook to be deduplicated away and silently fail to register. Includes a few ways to generate one (PowerShell, Visual Studio, uuidgen).
  • Verify the hook is wired up – guidance to inspect the generated SelfRegisteredExtensions.g.cs file and common reasons the call might be missing.

Also adds:

  • A [!TIP] callout at the top of the ## Extensibility points section pointing readers to the new section so they don't miss it while reading individual extension docs.
  • A ms.date bump.

Why

Issue microsoft/testfx#5552 (from @Youssef1313) called out that the article doesn't tell extension authors how to plug into the auto-generated entry point and doesn't make it clear that the registration GUID must be freshly generated. The article previously only showed the manual builder.TestHost.AddXxx(...) registration calls, leaving authors to reverse-engineer the pattern from in-box extension sources.

Content sources

Section Source
Hook class shape & signature Verified against Microsoft.Testing.Extensions.Retry/TestingPlatformBuilderHook.cs and the _expectedItemSpec constant in TestingPlatformAutoRegisteredExtensions.cs.
Props file shape & metadata Verified against Microsoft.Testing.Extensions.Retry.props and the MSBuild task's metadata constants.
Dedup-by-Include behavior Verified against ValidateAndDeduplicateBuilderHooks in TestingPlatformAutoRegisteredExtensions.cs.
Generated entry point shape Verified against GetSourceCode in TestingPlatformAutoRegisteredExtensions.cs.
Consumer opt-out (GenerateTestingPlatformEntryPoint=false) Consistent with existing wording in microsoft-testing-platform-intro.md, microsoft-testing-platform-features.md, and several extension articles in this repo.

Note

Per repo convention, the AI-usage frontmatter is unchanged (ai-assisted) because this article was already marked as such.

Validation

  • npx -y markdownlint-cli2 docs/core/testing/microsoft-testing-platform-architecture-extensions.md → 0 errors.
  • Internal anchors used (#auto-register-your-extension-with-testingplatformbuilderhook, #the-include-guid-is-a-random-identifier, ./microsoft-testing-platform-architecture.md#the-iextension-interface) were derived from the corresponding heading text per Docs anchor rules.

Closes microsoft/testfx#5552 (docs side).


Internal previews

📄 File 🔗 Preview link
docs/core/testing/microsoft-testing-platform-architecture-extensions.md Build extensions for Microsoft.Testing.Platform (MTP)

…on authors

Addresses microsoft/testfx#5552 by adding a new section to the MTP extensions architecture article that explains:

- How extension authors expose a TestingPlatformBuilderHook class and ship a buildMultiTargeting props file so consumers don't need manual registration.
- The required AddExtensions(ITestApplicationBuilder, string[]) method signature and the required MSBuild item metadata (Include, DisplayName, TypeFullName).
- That the Include GUID is a freshly generated, random identifier that must not be reused from any other extension (with an IMPORTANT callout) and is distinct from IExtension.Uid.
- How to verify the hook is wired up by inspecting the generated SelfRegisteredExtensions.g.cs file.

Also adds a TIP at the top of the Extensibility points section pointing readers to the new section, and bumps ms.date.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 14:05
@dotnetrepoman dotnetrepoman Bot added this to the June 2026 milestone Jun 2, 2026
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 pull request updates the Microsoft.Testing.Platform (MTP) extensions architecture documentation to explain how extension authors can participate in MSBuild-driven auto-registration via a TestingPlatformBuilderHook, so consumers don’t need to add manual registration calls in Main.

Changes:

  • Adds a new section that documents the TestingPlatformBuilderHook class shape, required method signature, and the MSBuild TestingPlatformBuilderHook item in a buildMultiTargeting/<PackageId>.props file.
  • Adds guidance about the Include GUID’s purpose (deduplication) and how to verify wiring via the generated SelfRegisteredExtensions.g.cs.
  • Adds a tip callout near the top of Extensibility points pointing readers to the new auto-registration section and bumps ms.date.
Show a summary per file
File Description
docs/core/testing/microsoft-testing-platform-architecture-extensions.md Documents TestingPlatformBuilderHook auto-registration, adds a cross-reference tip, and updates the article date.

Copilot's findings

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

Comment thread docs/core/testing/microsoft-testing-platform-architecture-extensions.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Evangelink Evangelink enabled auto-merge (squash) June 2, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve extensibility documentation

2 participants