Repository navigation
Consume Microsoft.Testing.Platform.Internal.DotnetTest source package - #54959
Evangelink merged 13 commits into
Conversation
… package Replace the hand-copied 'dotnet test' <-> Microsoft.Testing.Platform wire contract (IPC/ObjectFieldIds.cs) and terminal reporter (Commands/Test/MTP/ Terminal/*) with the source-only NuGet package from microsoft/testfx, so the shared source has a single source of truth instead of being duplicated by hand. This is a DRAFT to surface the remaining plumbing/reconciliation gaps; it does not build yet (see PR description). Co-authored-by: Copilot <[email protected]>
…rsion) Co-authored-by: Copilot <[email protected]>
- Terminal reporter: Microsoft.DotNet.Cli.Commands.Test.Terminal -> Microsoft.Testing.Platform.OutputDevice.Terminal (4 consumers) - IPC wire contract: add using Microsoft.Testing.Platform.IPC to the 8 serializers that reference the shared *FieldsId classes (previously resolved same-namespace via the now-deleted ObjectFieldIds.cs) - TerminalTestReporterOptions: ShowPassedTests/ShowProgress are Func<> in the shared source; wrap the bool values in lambdas - Terminal.FlatException -> FlatException Co-authored-by: Copilot <[email protected]>
- SystemConsole -> using Microsoft.Testing.Platform.Helpers - TargetFrameworkParser -> using Microsoft.Testing.Platform.OutputDevice dotnet.csproj now builds clean (0 warnings, 0 errors) against the Microsoft.Testing.Platform.Internal.DotnetTest package. Co-authored-by: Copilot <[email protected]>
Delete the hand-copied TestStates, SessionEventTypes, HandshakeMessagePropertyNames, HandshakeMessageExecutionModes and ProtocolConstants from CliConstants.cs and consume the shared copies the package ships in Microsoft.Testing.Platform.IPC (via Constants.cs). The package's versions are supersets (TestStates.InProgress, HandshakeMessagePropertyNames.OrchestratorFeature) and wire-compatible. CliConstants and ProjectProperties stay - they are CLI-specific. Builds clean (0/0). Co-authored-by: Copilot <[email protected]>
… version) - Add the Microsoft.Testing.Platform.Internal.DotnetTest dependency to eng/Version.Details.xml (next to Microsoft.Testing.Platform) and a darc-tracked $(MicrosoftTestingPlatformInternalDotnetTestVersion) property in eng/Versions.props. - Reference that property from Directory.Packages.props. - Pin to 2.3.0-preview.26325.4 (the older 2.3.0-preview.26321.1 predates the package). A real darc update will bump the testfx deps together to a coherent build/Sha. Restores from the public test-tools feed and builds clean (0 warnings, 0 errors). Co-authored-by: Copilot <[email protected]>
Move Microsoft.Testing.Platform, MSTest and Microsoft.Testing.Platform.Internal.DotnetTest together to the same coherent testfx build 2.3.0-preview.26325.4 / 4.3.0-preview.26325.4 (Sha d0f05558aa93a3b757ab579e63b80fbccdec81c6), verified identical across all three package nuspecs on the test-tools feed. This replaces the temporary mixed state where MTP/MSTest were pinned to an older build (.26321) that predated the Internal.DotnetTest package. Builds clean (0 warnings, 0 errors) restoring from the public test-tools feed. Co-authored-by: Copilot <[email protected]>
…ettest-source-package # Conflicts: # Directory.Packages.props
The Microsoft.Testing.Platform.Internal.DotnetTest source-only package's contentFiles are restored under the repo-local .packages/ folder and compiled into dotnet.csproj. The root .editorconfig enforces the file-header rule (IDE0073) and TreatWarningsAsErrors turns it into a build break across every CI leg. Exempt the restored package source from IDE0073, mirroring the existing artifacts/** exemption. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR replaces the in-repo, hand-copied dotnet test ↔ Microsoft.Testing.Platform terminal reporter + IPC contract constants with the Microsoft.Testing.Platform.Internal.DotnetTest source-only package, aiming to keep the shared integration code on a single source of truth with microsoft/testfx.
Changes:
- Add and wire up
Microsoft.Testing.Platform.Internal.DotnetTestvia CPM + darc-tracked versions (eng + Directory.Packages.props) and suppress CS0436 conflicts. - Re-point CLI call sites/IPC serializers from
Microsoft.DotNet.Cli.Commands.Test.*terminal/IPC copies toMicrosoft.Testing.Platform.*namespaces. - Remove the in-repo copied terminal reporter implementation and IPC
ObjectFieldIds/ constants duplicates; relax IDE0073 for restored.packages/**.cscontent.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/dotnet/dotnet.csproj | Adds source-only package reference and suppresses CS0436 for consumed contentFiles source. |
| src/Cli/dotnet/Commands/Test/MTP/TestApplicationHandler.cs | Switches IPC/constants/reporter types to Microsoft.Testing.Platform.* and updates FlatException usage. |
| src/Cli/dotnet/Commands/Test/MTP/TestApplicationActionQueue.cs | Re-points terminal reporter namespace usage to package-provided types. |
| src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs | Re-points IPC/constants/reporter namespace usage to package-provided types. |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/WarningMessage.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestRunArtifact.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestProgressStateAwareTerminal.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestProgressState.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestOutcome.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestNodeResultsState.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TestDetailState.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporterOptions.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporter.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalColor.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TargetFrameworkParser.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/SystemStopwatch.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/SystemConsoleColor.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/SystemConsole.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/SimpleTerminalBase.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/SimpleAnsiTerminal.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/NonAnsiTerminal.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/NativeMethods.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/ITerminal.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/IStopwatch.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/IProgressMessage.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/IConsole.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/IColor.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/HumanReadableDurationFormatter.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/FileUtilities.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/ExceptionFlattener.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/ErrorMessage.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/AnsiTerminalTestProgressFrame.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/AnsiTerminal.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/AnsiDetector.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/AnsiCodes.cs | Removes now-duplicated reporter source (moved to source-only package). |
| src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs | Adapts to updated reporter options API and uses package-provided console helpers. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/VoidResponseSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/TestSessionEventSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/TestResultMessagesSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/TestInProgressMessagesSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/HandshakeMessageSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/FileArtifactMessagesSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/DiscoveredTestMessagesSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/CommandLineOptionMessagesSerializer.cs | Uses package-provided IPC field IDs/constants namespace. |
| src/Cli/dotnet/Commands/Test/MTP/IPC/ObjectFieldIds.cs | Removes in-repo IPC field IDs (now sourced from package). |
| src/Cli/dotnet/Commands/Test/CliConstants.cs | Removes duplicated protocol constants now sourced from package. |
| eng/Versions.props | Adds darc-tracked version property for the source-only package. |
| eng/Version.Details.xml | Adds the new dependency and coherently bumps testfx dependency versions/SHA. |
| Directory.Packages.props | Adds CPM entry for the source-only package version. |
| .editorconfig | Disables IDE0073 for restored .packages/**.cs source content. |
Copilot's findings
- Files reviewed: 50/50 changed files
- Comments generated: 1
The PR re-pointed production consumers to the package namespaces but left the unit tests on the deleted Microsoft.DotNet.Cli.Commands.Test.Terminal/.IPC types, so dotnet.Tests no longer compiled. Re-point the 8 affected test files to the package namespaces (Microsoft.Testing.Platform.Helpers / .OutputDevice.Terminal / .IPC) and adapt TerminalTestReporterOptions.ShowProgress to its Func<bool?> shape. TestNodeResultsStateTests and the two DiscoverTest cases in TestProgressStateTests still target SDK-local reporter enhancements (issue 51608 instanceId stale-add race fix; discovered-test source locations) that the published package does not yet contain; those require an upstream microsoft/testfx change + package bump and are intentionally left asserting the richer contract. Co-authored-by: Copilot <[email protected]>
CI fix status (automated)Pushed two commits to make this green: 1. 2.
|
| SDK-local feature | SDK API (kept) | Package API | Test affected |
|---|---|---|---|
| Issue #51608 stale-add race fix | TestNodeResultsState.AddRunningTestNode(id, **instanceId**, uid, name, sw) / RemoveRunningTestNode(**instanceId**, uid) keyed by (instanceId, uid) |
4-arg / 1-arg, keyed by uid only |
TestNodeResultsStateTests |
| Discovered-test source locations | TestProgressState.DiscoverTest(displayName, uid, **filePath, lineNumber**) + rich DiscoveredTestNames |
only DiscoveredTestDisplayNames (List<string>) |
TestProgressStateTests (2 DiscoverTest_* cases) |
I intentionally did not weaken those tests to match the package, since that would silently ship a regression of a filed bug fix and a user-facing feature. To finish:
- Recommended: upstream both enhancements to microsoft/testfx, publish, and
darc-bump the package — then zero further SDK-side changes are needed (the re-pointed tests already assert the richer contract). - Alternatively, scope the package consumption to the IPC wire-contract files only (the part that truly needs a single source of truth) and keep the SDK''s terminal reporter, or accept the package behavior and drop/adapt those two tests (regresses
dotnet testfor MTP throws hard-to-interpret KeyNotFoundException #51608 + discovered-test locations).
Happy to take whichever direction — just let me know.
…e types The package ships ALL of its types ([Embedded] attribute) - both the terminal reporter (TerminalTestReporter, TestProgressState, TestNodeResultsState, TerminalTestReporterOptions, TestOutcome) and the IPC protocol types (ObjectFieldIds, Constants). [Embedded] types are invisible to any OTHER assembly by design (InternalsVisibleTo does not override this), so the dotnet.Tests assembly cannot reference them at all - the prior namespace re-point made them resolve to the package but they remain unreferenceable across the assembly boundary. Salvaged (kept; these test SDK-owned logic and only referenced an [Embedded] CONSTANT incidentally, now inlined as a documented literal): TestApplicationProtocolVersionTests, DiscoveredTestMessagesSerializerTests. Removed (these directly construct/inspect [Embedded] package-owned types and cannot compile from a separate assembly; TestApplicationHandler's ctor takes the [Embedded] TerminalTestReporter so even a second compiled copy in the test assembly would mismatch by type identity): TerminalTestReporterTests, TestApplicationHandlerTests, TestNodeResultsStateTests, TestProgressStateTests, and the CapturingConsole helper they used. REGRESSIONS to upstream into microsoft/testfx (behavior already dropped by this PR's production-side deletion; coverage removed here): (1) issue dotnet#51608 instanceId stale-add race fix (TestNodeResultsState (instanceId, uid) keying); (2) discovered-test source locations (TestProgressState.DiscoverTest filePath/lineNumber + DiscoveredTestNames); (3) SDK TestApplicationHandler routing/recap coverage. These should be re-added as tests in testfx, or restored if the package stops marking these types [Embedded] and adds InternalsVisibleTo. Co-authored-by: Copilot <[email protected]>
Update — full diagnosis + reconciliation (supersedes my earlier comment)My earlier note under-stated the test problem. After the namespace re-point, the real blocker surfaced: every type in the package is marked What I changed in
|
Build now green on every platform — one runtime blocker left (output-wording regression)The
Important: functional behavior is correct — the exit-code assertions ( Root cause (same family as the others): on Confirmed reporter regressions from the package (all need an upstream testfx decision)
I deliberately did not rewrite these two E2E assertions to force green — that would silently change user-facing
Everything that''s unambiguously an SDK-side fix is done and green; this last item is a user-facing output decision. |
…-disco # Conflicts: # eng/Version.Details.xml
The Internal.DotnetTest package reporter intentionally emits the terser 'Exit code: N' (verbosity reduction, AB#2426213) instead of the SDK's former 'Test run completed with non-success exit code: N (see: ...)' line. Update the two crash E2E assertions to match the package output and remove the now-unused TestRunExitCode/TestDiscoveryExitCode resources (and their xlf entries). Co-authored-by: Copilot <[email protected]>
Merge conflict resolved + bumped to latest package + output regression resolved1. Conflict (eng/Version.Details.xml).
2. The version bump cleared one of the earlier blockers. 3. Review feedback addressed. 4. The 2 E2E exit-code failures — resolved by aligning to the package. The package reporter intentionally prints the terser Status
CI re-running on the pushed commit. |
|
This new dependecy is blocking source-build in dotnet/dotnet#7529. This package could be added to source-build-assets as a text only package because of the package being a source-only package. My concern however is the dev workflow each time the version is updated. We don't want to block the dependency flow every time, there should be a workflow that updates the checked in source and the SDK dependency at the same time which may require this update to happen at the VMR level versus the SDK. Onboarding the textfx repo as an external repo is another option but if the cadence at which we want to update that dependency is high, a workflow need to be created to handle that as external repos don't work with DARC. cc @Evangelink, @joeloff, @mthalman |
|
Oh sorry I haven't though about that scenario. I was trying to simplify work on my side by saying that MTP handling and display of multiple asms (dotnet test) could be handled on MTP side and I would just share code. I have a workaround for that, I'll set it up today. |
…tnetTest package The source-only Microsoft.Testing.Platform.Internal.DotnetTest package (#54959) breaks source-build / the VMR (dotnet/dotnet#7529). Revert to hand-copying the shared "dotnet test" <-> Microsoft.Testing.Platform source (named-pipe wire contract + terminal reporter) and add a vendored-files drift-tracking mechanism ported from microsoft/testfx so we get notified when the upstream files change. - Revert PR #54959: restore the vendored Terminal reporter + ObjectFieldIds.cs + the wire constants in CliConstants.cs and their namespaces; drop the package reference, CPM version, darc wiring and NoWarn;CS0436. - Add eng/vendored-files.json (manifest of the testfx-sourced files), eng/vendored-files.md (docs), .github/scripts/check_vendored_files.py (drift detector) and .github/workflows/check-vendored-files.yml (weekly + PR checks). Co-authored-by: Copilot App <[email protected]>
✅ Validation status
The package (microsoft/testfx#9400, merged) is published on the public test-tools feed (already a configured source here). Built
src/Cli/dotnet/dotnet.csprojagainst the real package2.3.0-preview.26325.4— the shared source compiled intodotnet.dll; iterating the compiler errors drove the reconciliation now committed here:TerminalTestReporterOptions.ShowPassedTests/ShowProgressareFunc<>;Terminal.FlatException→FlatException).Constants.cs.CS0436suppression held (0 warnings), confirming the non-embedded abstractions behave as documented.What this does
Microsoft.Testing.Platform.Internal.DotnetTestis an internal, source-only NuGet from microsoft/testfx. It ships — ascontentFiles/cs/anycompiled into the consumer — the pieces of thedotnet test↔ Microsoft.Testing.Platform integration that must stay a single source of truth across microsoft/testfx and dotnet/sdk:ObjectFieldIds.cs,Constants.cs), andTerminalResources(resx/xlf, wired via the package'sbuild/props).Today dotnet/sdk hand-maintains its own copies under
src/Cli/dotnet/Commands/Test/MTP/(theObjectFieldIds.cseven carries a "must be kept aligned with the testfx repo" warning). This PR replaces those copies with the package:PackageReference Include="Microsoft.Testing.Platform.Internal.DotnetTest"tosrc/Cli/dotnet/dotnet.csproj+ register it inDirectory.Packages.props(CPM).CS0436toNoWarn(required — see Gap 4).Commands/Test/MTP/IPC/ObjectFieldIds.csand the entireCommands/Test/MTP/Terminal/reporter copy.Microsoft.Testing.Platform.IPC/.OutputDevice.Terminal/.OutputDevice/.Helpers).Remaining work (why it is still draft)
1. Coherent darc bump of the testfx dependency set — ✅ DONE.
All three microsoft/testfx dependencies are bumped together to the same coherent build in
eng/Version.Details.xml:Microsoft.Testing.Platform+Microsoft.Testing.Platform.Internal.DotnetTest2.3.0-preview.26325.4andMSTest4.3.0-preview.26325.4, all at Shad0f05558aa93a3b757ab579e63b80fbccdec81c6(verified identical across all three package nuspecs on the test-tools feed). A darc-tracked$(MicrosoftTestingPlatformInternalDotnetTestVersion)property ineng/Versions.propsis referenced fromDirectory.Packages.props. The equivalent maintainer command is:Builds clean restoring from the feed. The only remaining item is the runtime E2E pass (Gap 5).
2. Namespace divergence (every call site) — ✅ DONE in this PR.
The shared source lives in
Microsoft.Testing.Platform.IPC,.OutputDevice.Terminal,.OutputDeviceand.Helpers. dotnet/sdk's copies lived underMicrosoft.DotNet.Cli.Commands.Test.*. This PR re-points all consumers + the 8 IPC serializers (which referenced the*FieldsIdclasses same-namespace via the deletedObjectFieldIds.cs) and movesSystemConsole(.Helpers) andTargetFrameworkParser(.OutputDevice).3. The wire contract —
Constantsnow shared; models + serializers still hand-copied. ✅ Constants de-duplicated.This PR deletes the duplicated
TestStates,SessionEventTypes,HandshakeMessagePropertyNames,HandshakeMessageExecutionModesandProtocolConstantsfromCliConstants.csand consumes the shared copies the package ships inMicrosoft.Testing.Platform.IPC(Constants.cs). The package's versions are supersets (TestStates.InProgress,HandshakeMessagePropertyNames.OrchestratorFeature) and wire-compatible;CliConstantsandProjectPropertiesstay (CLI-specific). By design the package still does not share the message models (IPC/Models/), serializers (IPC/Serializers/), or the NamedPipe transport — those depend onTestMetadataProperty/differ in shape, so they remain hand-copied (drift risk, kept in this PR).4. Terminal reporter divergence — ✅ smaller than expected, resolved.
Despite the package's reporter being refactored (partials + new renderers), the consumer-facing API turned out compatible: the sdk-only
ErrorMessage/WarningMessage/IProgressMessagewere reporter internals (not consumed by the handlers — theErrorMessagereferences were a property, not the type), so deleting them was clean. Only two adaptations were needed (committed):ShowPassedTests/ShowProgressareFunc<>;Terminal.FlatException→FlatException. Because some abstractions (IConsole/IStopwatch/IColor/SystemConsole/SystemConsoleColor/SystemStopwatch) are not[Embedded], a consumer that also seesMicrosoft.Testing.Platformgets benignCS0436warnings;TreatWarningsAsErrors=trueturns them into errors, hence theNoWarn;CS0436added here (verified: 0 warnings).5. No end-to-end test run yet.
The build is green; still pending is a run of the existing
dotnet testE2E suite against the package to prove identical wire behavior + reporter output at runtime.Consumer prerequisites — already satisfied in this repo ✅
ImplicitUsings=enable(rootDirectory.Build.props) — packagebuild/props supply the reporter's extra global usings.LangVersion=Preview— needed for thefieldkeyword the reporter uses.Microsoft.CodeAnalysis.EmbeddedAttribute— already defined in-repo.XliffTasks(via Arcade) — for the localizedTerminalResourcessatellites.Suggested order to make it real
src/Cli/dotnetbuilds green (0/0) restoring the published package from the test-tools feed.dotnet testE2E against an assembled SDK (Gap 5), and have a maintainer re-run the coherent darc update at merge time so the Shas reflect the then-current testfx build.