Add a source-only MTP server-mode client package
Merged
NO
3mo ago+6164+6164+0123456789012345678901234567890123456789-155-155-012345678901234567890123456789
MTP ships only the server side of its server-mode JSON-RPC protocol today, so consumers that drive an MTP test app have had to maintain bespoke clients. This adds one canonical client, owned in testfx next to the protocol it implements, and ships it as source so vstest, VSUnitTesting, and C# Dev Kit can replace their copies without adding a runtime dependency.
What's here
- A new
src/Platform/Microsoft.Testing.Platform.ServerMode.Client.Sourcesproject that links the server's protocol and serialization source and adds the client API, JSON-RPC connection, and process launcher. - A source-only
Microsoft.Testing.Platform.ServerMode.Client.Sourcespackage: no DLL, no runtime dependency, and all injected types are internal. - Package-private namespaces for linked protocol types, so consumers can reference
Microsoft.Testing.Platform.dllwithout source/assembly type collisions. - Dependency-free, Native AOT-compatible serialization: Jsonite for .NET Framework, netstandard2.0, and net5.0-net7.0 consumers; in-box System.Text.Json for net8.0 and newer.
- Synchronous and asynchronous launch APIs, cancellation-aware connection startup, event-safe lazy read-loop startup, and synchronized server-request handlers.
- A curated set of down-level polyfills with explicit opt-out constants for consumers that already define common source polyfills.
Validation
- Unit coverage exercises initialize, discover, run, filters, notifications, server requests, cancellation, malformed frames, disconnects, and both formatter paths on net462 and modern .NET.
- A packed hostile-consumer compile gate covers net462, netstandard2.0, net5.0, net6.0, net7.0, and net8.0 with nullable analysis and warnings-as-errors while also referencing
Microsoft.Testing.Platform. - A packed end-to-end consumer launches a real MTP app and verifies discovery and execution over the wire.
- Package contract tests verify source-only layout, content-file manifests, namespace isolation, per-TFM formatter selection, curated polyfills, and build assets.
- System.Text.Json and Jsonite preserve equivalent untyped numeric representations, including integers through
decimal.MaxValue.
Scope
This PR is the testfx/package leg. Adoption in vstest, VSUnitTesting, and C# Dev Kit remains separate so each consumer can remove its bespoke implementation and adapt its repository-specific integration independently.