Stabilize extension UIDs and add naming governance (#9757)#9773
Conversation
Replace nameof(ClassName) UID/providerName arguments with explicit stable string literals across the well-known command-line providers so IDE renames no longer silently change telemetry hashes, --info output, and artifact metadata. Values are unchanged. - Document the UID stability requirement on IExtension.Uid. - Give MSBuildCommandLineProvider a user-facing DisplayName resource instead of leaking the internal class name in --info. - Assert stable string literals (not nameof) in NopPlatformOutputDeviceTests. - Add WellKnownExtensionUidTests as a fast UID snapshot tripwire. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR hardens Microsoft.Testing.Platform (MTP) extension UID governance by documenting UID stability requirements and replacing nameof(...)-derived UIDs with stable literals in well-known command-line providers, preventing silent UID changes during refactors and improving --info output readability.
Changes:
- Documented that
IExtension.Uidmust be a stable constant (not derived fromnameof(ImplementingClass)). - Replaced
nameof(...)UIDs with stable string literals across well-known command-line providers (preserving existing UID values). - Added/updated tests to pin UIDs and updated acceptance expectations for the MSBuild provider display name.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/NopPlatformOutputDeviceTests.cs | Pins NopPlatformOutputDevice UID/DisplayName via string literals so renames become test-breaking. |
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/WellKnownExtensionUidTests.cs | Adds unit-test “tripwire” snapshot assertions for platform-owned provider UIDs. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs | Updates --info expectation for the MSBuild provider display name. |
| src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Platform/Extensions/IExtension.cs | Documents UID stability requirements and rationale in XML docs. |
| src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.VideoRecorder/VideoRecorderCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCommandLine.cs | Uses a stable literal UID for the TRX report generator command line. |
| src/Platform/Microsoft.Testing.Extensions.Retry/RetryCommandLineOptionsProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildCommandLineProvider.cs | Switches to a stable literal UID and replaces display name with a localized resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/ExtensionResources.resx | Adds localized display name resource for MSBuild command-line provider. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.cs.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.de.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.es.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.fr.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.it.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.ja.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.ko.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.pl.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.pt-BR.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.ru.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.tr.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.zh-Hans.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Resources/xlf/ExtensionResources.zh-Hant.xlf | Regenerated XLF entry for new MSBuild provider display name resource. |
| src/Platform/Microsoft.Testing.Extensions.JUnitReport/JUnitReportGeneratorCommandLine.cs | Uses a stable literal UID for the JUnit report generator command line. |
| src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportGeneratorCommandLine.cs | Uses a stable literal UID for the HTML report generator command line. |
| src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportGeneratorCommandLine.cs | Uses a stable literal UID for the CTRF report generator command line. |
| src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsCommandLineProvider.cs | Uses a stable literal UID (with “do not change” guidance). |
Review details
- Files reviewed: 31/31 changed files
- Comments generated: 0
- Review effort level: Low
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
✅ 22/22 dimensions clean — no findings.
Summary: Well-scoped, purely mechanical PR. All 12 nameof() → string literal conversions preserve the exact same runtime UID values, so telemetry continuity is unaffected. The MSBuild display name fix correctly moves from the leaked class name to a proper localized resource. The new WellKnownExtensionUidTests pinning test and the hardened NopPlatformOutputDeviceTests assertion will trip on any future accidental rename. Localization (.resx + regenerated .xlf) follows repo conventions, and the --info acceptance test expectation is updated to match the new display name.
🧪 Test quality grade — PR #9773
This advisory comment was generated automatically. Grades are heuristic
|
…nternalAPI declarations - Normalize array initialization in 3 DotnetTest IPC serializers to use empty array `= []` pattern instead of nullable `= null` with `?? []` fallback, matching the style used by DiscoveredTestMessagesSerializer and TestInProgressMessagesSerializer (introduced in PR #9774) - Add missing InternalAPI.Unshipped.txt declarations for ReadFields and WriteListPayload methods added to BaseSerializer in PR #9774, across Microsoft.Testing.Platform and its 4 extension projects that link BaseSerializer.cs as a shared source file (HangDump, TrxReport, Retry, MSBuild) - Add missing InternalAPI.Unshipped.txt declaration for PlatformServicesConfigurationAdapter class added in PR #9773 to MSTest.TestAdapter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes #9757.
Every MTP extension / command-line provider exposes
IExtension.Uid, which is SHA-256-hashed for telemetry, printed verbatim in--info, embedded in artifact metadata, and used for feature detection. Many providers derived that value fromnameof(ClassName), so an IDE "Rename Symbol" refactor would silently change the UID. This PR addresses all five tasks in the issue.Changes
Task 1 — Document the stability requirement
IExtension.UidXML doc now states the value must be a stable string constant that survives class renames and must not usenameof(ImplementingClass).Task 2 — Fix
MSBuildCommandLineProviderDisplayNamenameof(MSBuildCommandLineProvider)as bothuidanddisplayName, so--infoleaked the internal class name. Added a localizedMSBuildCommandLineProviderDisplayName= "MSBuild integration" resource (xlf regenerated) and use it as the display name. UID is unchanged.Task 3 — Replace
nameof()UIDs with stable literalsproviderNameargument to an explicit string literal (same value) in the 12 remaining well-known command-line providers:PlatformCommandLineProvider,TerminalTestReporterCommandLineOptionsProvider,CrashDumpCommandLineProvider,HangDumpCommandLineProvider,RetryCommandLineOptionsProvider, the four report generators (Trx/JUnit/Html/Ctrf),AzureDevOpsCommandLineProvider,GitHubActionsCommandLineProvider, andVideoRecorderCommandLineProvider. Each carries a short "do not change" comment. No UID values change, so telemetry continuity is preserved.Task 4 — Fix
NopPlatformOutputDeviceTestsnameof(NopPlatformOutputDevice)on both sides, so a rename would silently update rather than fail. It now asserts the string literal directly, turning a rename into a conspicuous failure.Task 5 — UID snapshot coverage
--infoacceptance tests already assert provider UIDs as section headers. AddedWellKnownExtensionUidTestsas a fast, dependency-free unit-test tripwire pinning the platform-owned provider UIDs.Validation
WellKnownExtensionUidTests+NopPlatformOutputDeviceTestspass (5/5).--infoall-extensions acceptance expectation (HelpInfoAllExtensionsTests) soName: MSBuild integrationmatches the new display name.