Skip to content

Expose experimental API for custom output devices in MTP#8585

Draft
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/mtp-custom-output-device
Draft

Expose experimental API for custom output devices in MTP#8585
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/mtp-custom-output-device

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Adds a new experimental public API in Microsoft.Testing.Platform that allows consumers to plug in a custom output device.

What's new

New experimental (TPEXP) public surface:

  • Microsoft.Testing.Platform.OutputDevice.ICustomOutputDevice — minimal user-facing interface (DisplayBannerAsync, DisplayBeforeSessionStartAsync, DisplayAfterSessionEndRunAsync, DisplayAsync).
  • Microsoft.Testing.Platform.OutputDevice.IOutputDeviceManager with SetOutputDevice(Func<IServiceProvider, ICustomOutputDevice>).
  • ITestApplicationBuilder.OutputDevice { get; } — manager accessor (mirrors the existing Logging / Configuration pattern).

Design notes

  • ICustomOutputDevice is intentionally separate from the internal IPlatformOutputDevice so we don't have to expose TestProcessRole. An internal CustomOutputDeviceAdapter bridges the two.
  • SetOutputDevice throws InvalidOperationException on duplicate registration (consistent with RegisterTestFramework). New localized resource: PlatformOutputDeviceAlreadyRegisteredErrorMessage.
  • ServerModePerCallOutputDevice still runs in parallel through ProxyOutputDevice when a custom device is registered — preserves current server-mode behavior.
  • Hot-reload (IHotReloadPlatformOutputDevice) remains internal: custom devices do not participate in the hot-reload-specific lifecycle (documented limitation).
  • When the custom device's IsEnabledAsync returns false, the platform falls back to the default terminal output device.

Verification

  • ✅ Build clean (0 warnings, 0 errors) on net8.0 / net9.0 / netstandard2.0.
  • ✅ XLF regenerated for all 13 locales.
  • ✅ 12/12 OutputDevice unit tests and 260/260 CommandLine|Builder|TestHost unit tests pass.

Adds a new experimental public API allowing users to plug a custom
output device into Microsoft.Testing.Platform.

New public types (TPEXP):
- Microsoft.Testing.Platform.OutputDevice.ICustomOutputDevice
- Microsoft.Testing.Platform.OutputDevice.IOutputDeviceManager
- ITestApplicationBuilder.OutputDevice property

Design notes:
- ICustomOutputDevice is a minimal user-facing interface that does not
  expose the internal IPlatformOutputDevice or TestProcessRole. An
  internal CustomOutputDeviceAdapter bridges to the existing pipeline.
- IOutputDeviceManager.SetOutputDevice throws InvalidOperationException
  if called more than once (consistent with RegisterTestFramework).
- Server-mode ServerModePerCallOutputDevice and hot-reload behavior
  are preserved unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 21:57
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 adds a new experimental (TPEXP) extensibility point in Microsoft.Testing.Platform (MTP) that lets consumers register a custom output device to replace the default terminal output, while preserving existing server-mode (JSON-RPC) output behavior via the existing proxying pipeline.

Changes:

  • Introduces new experimental public APIs: ICustomOutputDevice, IOutputDeviceManager, and ITestApplicationBuilder.OutputDevice.
  • Implements a bridging adapter (CustomOutputDeviceAdapter) and wires registration + enablement fallback logic into the platform output device manager.
  • Adds a new localized resource string (PlatformOutputDeviceAlreadyRegisteredErrorMessage) and updates XLF locale files accordingly.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf Adds new localized trans-unit entry for duplicate output device registration error message.
src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx Adds the new resource key/value for duplicate output device registration.
src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Unshipped.txt Declares the new experimental public API surface for API compatibility tooling.
src/Platform/Microsoft.Testing.Platform/OutputDevice/OutputDeviceManager.cs Implements single-registration enforcement, custom device registration, and fallback to default output device when disabled.
src/Platform/Microsoft.Testing.Platform/OutputDevice/IOutputDeviceManager.cs Adds the new experimental manager interface used to register custom output devices.
src/Platform/Microsoft.Testing.Platform/OutputDevice/ICustomOutputDevice.cs Adds the new experimental custom output device interface consumers implement.
src/Platform/Microsoft.Testing.Platform/OutputDevice/CustomOutputDeviceAdapter.cs Bridges ICustomOutputDevice into the internal IPlatformOutputDevice pipeline.
src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs Exposes the output device manager from the host builder.
src/Platform/Microsoft.Testing.Platform/Hosts/ITestHostBuilder.cs Adds OutputDevice to the internal test host builder contract.
src/Platform/Microsoft.Testing.Platform/Builder/TestApplicationBuilder.cs Exposes ITestApplicationBuilder.OutputDevice to consumers (experimental).
src/Platform/Microsoft.Testing.Platform/Builder/ITestApplicationBuilder.cs Adds the experimental OutputDevice accessor to the public builder interface.

Copilot's findings

  • Files reviewed: 23/23 changed files
  • Comments generated: 0

@Evangelink Evangelink marked this pull request as draft May 26, 2026 07:03
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.

2 participants