Expose experimental API for custom output devices in MTP#8585
Draft
Evangelink wants to merge 1 commit into
Draft
Expose experimental API for custom output devices in MTP#8585Evangelink wants to merge 1 commit into
Evangelink wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
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, andITestApplicationBuilder.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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new experimental public API in
Microsoft.Testing.Platformthat 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.IOutputDeviceManagerwithSetOutputDevice(Func<IServiceProvider, ICustomOutputDevice>).ITestApplicationBuilder.OutputDevice { get; }— manager accessor (mirrors the existingLogging/Configurationpattern).Design notes
ICustomOutputDeviceis intentionally separate from the internalIPlatformOutputDeviceso we don't have to exposeTestProcessRole. An internalCustomOutputDeviceAdapterbridges the two.SetOutputDevicethrowsInvalidOperationExceptionon duplicate registration (consistent withRegisterTestFramework). New localized resource:PlatformOutputDeviceAlreadyRegisteredErrorMessage.ServerModePerCallOutputDevicestill runs in parallel throughProxyOutputDevicewhen a custom device is registered — preserves current server-mode behavior.IHotReloadPlatformOutputDevice) remains internal: custom devices do not participate in the hot-reload-specific lifecycle (documented limitation).IsEnabledAsyncreturnsfalse, the platform falls back to the default terminal output device.Verification
OutputDeviceunit tests and 260/260CommandLine|Builder|TestHostunit tests pass.