From 6472e529115eed35f46c44bda3d52952e8f6017e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 21 Jul 2026 16:13:00 +0200 Subject: [PATCH 01/20] Add WebSocket transport for the dotnettestcli protocol (browser-wasm support) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decouples the 'dotnet test' pipe protocol from System.IO.Pipes so it can bootstrap on runtimes without named-pipe support (browser-wasm), while keeping the existing '--server dotnettestcli --dotnet-test-pipe ' behavior and wire format byte-for-byte unchanged. Core transport refactor: - Widen NamedPipeConnectionBase.WriteMessageAsync/ReadNextMessageAsync from PipeStream to Stream; isolate WaitForPipeDrain behind an 'is PipeStream' check. - DotnetTestConnection now talks to an IClient (NamedPipeClient or DotnetTestWebSocketClient) instead of hard-coding NamedPipeClient, resolved via the new DotnetTestTransportKind/TryGetDotnetTestTransport. New WebSocket transport: - ClientWebSocketDuplexStream adapts System.Net.WebSockets.WebSocket to a Stream for non-browser runtimes. - BrowserWebSocketDuplexStream talks to the browser's native WebSocket via JSImport/JSExport (same pattern as BrowserOutputDevice), with a self-contained embedded JS module imported through a data: URL. - DotnetTestWebSocketClient implements IClient over either adapter, appending the per-run auth token as a query-string parameter (browsers can't set custom headers on the WebSocket handshake - same approach ASP.NET Core SignalR uses). CLI/validation: - New hidden options --dotnet-test-transport, --dotnet-test-websocket-endpoint, --dotnet-test-websocket-token. - PlatformCommandLineProvider rejects conflicting/incomplete transport option combinations and the named-pipe transport on browser-wasm/wasi-wasm early, with actionable messages. Protocol: - Additive handshake property Transport (id 16, NamedPipe/WebSocket) for diagnostics; ProtocolConstants.SupportedVersions bumped to 1.5.0. - docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md updated to describe the transport-neutral protocol and the new WebSocket transport (§15). Known gaps documented in §15.6: the reverse server-control channel stays named-pipe-only (disabled on browser/wasi), wasi-wasm has no transport yet, and stdio multiplexing was deliberately not attempted. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 282499c0-c68f-41eb-890a-ad47bb78ce54 --- .../004-protocol-dotnet-test-pipe.md | 165 ++++++++++- .../InternalAPI/InternalAPI.Shipped.txt | 2 - .../InternalAPI/InternalAPI.Unshipped.txt | 2 + .../InternalAPI.Shipped.txt | 2 - .../InternalAPI.Unshipped.txt | 2 + .../InternalAPI/InternalAPI.Shipped.txt | 2 - .../InternalAPI/InternalAPI.Unshipped.txt | 2 + .../InternalAPI/InternalAPI.Shipped.txt | 2 - .../InternalAPI/InternalAPI.Unshipped.txt | 2 + .../PlatformCommandLineProvider.cs | 99 ++++++- .../IPC/NamedPipeConnectionBase.cs | 33 ++- .../InternalAPI/InternalAPI.Shipped.txt | 2 - .../InternalAPI/InternalAPI.Unshipped.txt | 40 +++ .../Resources/PlatformResources.cs | 14 + .../Resources/PlatformResources.resx | 40 +++ .../Resources/xlf/PlatformResources.cs.xlf | 50 ++++ .../Resources/xlf/PlatformResources.de.xlf | 50 ++++ .../Resources/xlf/PlatformResources.es.xlf | 50 ++++ .../Resources/xlf/PlatformResources.fr.xlf | 50 ++++ .../Resources/xlf/PlatformResources.it.xlf | 50 ++++ .../Resources/xlf/PlatformResources.ja.xlf | 50 ++++ .../Resources/xlf/PlatformResources.ko.xlf | 50 ++++ .../Resources/xlf/PlatformResources.pl.xlf | 50 ++++ .../Resources/xlf/PlatformResources.pt-BR.xlf | 50 ++++ .../Resources/xlf/PlatformResources.ru.xlf | 50 ++++ .../Resources/xlf/PlatformResources.tr.xlf | 50 ++++ .../xlf/PlatformResources.zh-Hans.xlf | 50 ++++ .../xlf/PlatformResources.zh-Hant.xlf | 50 ++++ .../DotnetTest/DotnetTestConnection.cs | 103 +++++-- .../ServerMode/DotnetTest/DotnetTestHelper.cs | 47 ++++ .../ServerMode/DotnetTest/IPC/Constants.cs | 28 +- .../DotnetTest/IPC/DotnetTestDataConsumer.cs | 1 - .../Transport/BrowserWebSocketDuplexStream.cs | 257 ++++++++++++++++++ .../Transport/ClientWebSocketDuplexStream.cs | 109 ++++++++ .../Transport/DotnetTestWebSocketClient.cs | 204 ++++++++++++++ .../DotnetTestPipeBaselineTests.cs | 9 +- .../HelpInfoAllExtensionsTests.cs | 12 + .../HelpInfoTests.cs | 12 + .../DotnetTestProtocolContractTests.cs | 13 +- .../PlatformCommandLineProviderTests.cs | 133 +++++++++ .../IPC/DotnetTestWebSocketClientTests.cs | 233 ++++++++++++++++ .../IPC/ProtocolTests.cs | 2 +- 42 files changed, 2150 insertions(+), 72 deletions(-) create mode 100644 src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs create mode 100644 src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs create mode 100644 src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs create mode 100644 test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs diff --git a/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md b/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md index d9bd5efabc..8a37c17c3f 100644 --- a/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md +++ b/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md @@ -1,10 +1,29 @@ # 004 - `dotnet test` Named-Pipe Protocol This document is the descriptive specification of the **`dotnet test` pipe protocol** (a.k.a. the -`dotnettestcli` protocol): the small, versioned, **binary** protocol used over a named pipe between a +`dotnettestcli` protocol): the small, versioned, **binary** protocol used between a Microsoft.Testing.Platform (MTP) test application and the `dotnet test` implementation shipped in the .NET SDK. +> [!IMPORTANT] +> **Protocol vs. transport.** The wire protocol described in this document - message shapes, serializer +> IDs, field IDs, the handshake, versioning - is **transport-neutral**. It is defined purely in terms of a +> duplex byte stream: whoever creates the stream, and how, is a separate concern. Two transports exist +> today: +> +> - **Named pipe** (`System.IO.Pipes`, §3) - the original and still-default transport, activated by +> `--dotnet-test-pipe `. Everything in §3 through §13 below describes this transport unless noted. +> - **WebSocket** (§15) - required on runtimes that cannot open named pipes (`browser-wasm`), and optional +> elsewhere, activated by `--dotnet-test-transport websocket` plus `--dotnet-test-websocket-endpoint` +> and `--dotnet-test-websocket-token`. +> +> Sections 4 ("Framing"), 5 ("Body serialization format"), 6 ("Serializer registry"), 7 ("Request/reply +> model"), 8 ("Handshake & version negotiation"), 9 ("Message catalog"), and 10 ("Versioning & +> compatibility") apply **identically** to both transports - they operate on "the stream", not +> specifically "the pipe". Only §3 ("Pipe naming & transport") and §11-§12 (connection-loss and the +> reverse control channel) describe named-pipe-specific behavior; see §15 for the WebSocket equivalents +> and the (currently pipe-only) gaps. + It is a *different* protocol from the [JSON-RPC server-mode protocol](./001-protocol-intro.md): | | JSON-RPC server mode | `dotnet test` pipe protocol (this doc) | @@ -70,12 +89,18 @@ Rules and behavior: - `--server` accepts zero or one argument. The value `dotnettestcli` (case-insensitive) selects this protocol. `--server jsonrpc` (or `--server` with no value) selects JSON-RPC server mode instead. -- `--server dotnettestcli` **requires** `--dotnet-test-pipe`; command-line validation fails otherwise - (`PlatformCommandLineDotnetTestCliRequiresPipe`). +- `--server dotnettestcli` **requires** exactly one pre-launch transport to be fully specified: either + `--dotnet-test-pipe` (the default named-pipe transport, §3) or `--dotnet-test-transport websocket` + together with `--dotnet-test-websocket-endpoint` and `--dotnet-test-websocket-token` (§15). Specifying + neither, both, or an incomplete WebSocket option set fails command-line validation with an actionable + message (`PlatformCommandLineDotnetTestCliRequiresPipe`, `PlatformCommandLineDotnetTestTransportConflict`, + `PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken`, ...). Selecting the named-pipe transport + on a runtime that cannot open one (`browser-wasm`, `wasi-wasm`) also fails validation early instead of + crashing deep inside the connection bootstrap. - `--dotnet-test-pipe` takes **exactly one** argument: the fully-resolved OS pipe name/path the SDK is already listening on (see §3). -- Both options are built-in and **hidden**: the platform omits them from `--help`, so they are only - listed by `--info`. They are not meant for direct end-user use. +- All of these options are built-in and **hidden**: the platform omits them from `--help`, so they are + only listed by `--info`. They are not meant for direct end-user use. ### Environment variables @@ -345,6 +370,7 @@ Property IDs (`HandshakeMessagePropertyNames`): | 13 | `AttemptNumber` | test host only | Positive, 1-based retry attempt. Multiple Instance IDs may share one attempt. | | 14 | `SupportedPostProcessorKinds` | test host, server test host, test host controller, or artifact post-processor | Semicolon-separated reverse-DNS artifact kinds supported by registered post-processors. | | 15 | `SupportedPostProcessorExtensionsLegacy` | test host, server test host, test host controller, or artifact post-processor | Semicolon-separated lowercase file extensions used as a fallback for untagged artifacts. | +| 16 | `Transport` | yes | Which transport carried this handshake: `NamedPipe` or `WebSocket` (`HandshakeMessageTransportNames`). Diagnostic/negotiation-only - the wire protocol itself never varies by transport. | ### 8.2 SDK → host: `HandshakeMessage` (reply) @@ -360,7 +386,7 @@ The SDK replies with its own `HandshakeMessage`. The host reads these properties ### 8.3 Negotiation algorithm -The host advertises `ProtocolConstants.SupportedVersions` (currently `"1.0.0;1.1.0;1.2.0;1.3.0;1.4.0"`). +The host advertises `ProtocolConstants.SupportedVersions` (currently `"1.0.0;1.1.0;1.2.0;1.3.0;1.4.0;1.5.0"`). The SDK picks the **highest version present in both sets** and returns that single value. The host then: - Confirms the returned value is in its supported set (compatibility gate). @@ -662,14 +688,135 @@ own Execution ID (see §1/§2). | Concern | File(s) | | --- | --- | | Wire contract (IDs, field IDs) | `ServerMode/DotnetTest/IPC/ObjectFieldIds.cs` | -| Constants (states, versions, handshake props) | `ServerMode/DotnetTest/IPC/Constants.cs` | +| Constants (states, versions, handshake props, transport names) | `ServerMode/DotnetTest/IPC/Constants.cs` | | Serializer registry | `IPC/Serializers/RegisterSerializers.cs` | | Serializer primitives / envelope | `IPC/Serializers/BaseSerializer.cs`, `NamedPipeSerializer.cs` | -| Framing / transport | `IPC/NamedPipeConnectionBase.cs`, `NamedPipeServer.cs`, `NamedPipeClient.cs` | +| Shared duplex-stream framing (both transports) | `IPC/NamedPipeConnectionBase.cs` | +| Named-pipe transport | `IPC/NamedPipeServer.cs`, `IPC/NamedPipeClient.cs` | | Pipe naming | `NamedPipeServer.GetPipeName` | +| WebSocket transport | `ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs`, `ClientWebSocketDuplexStream.cs`, `BrowserWebSocketDuplexStream.cs` | +| Transport selection / CLI options | `CommandLine/PlatformCommandLineProvider.cs`, `ServerMode/DotnetTest/DotnetTestHelper.cs` (`DotnetTestTransportKind`) | | Message models | `ServerMode/DotnetTest/IPC/Models/*.cs`, `IPC/Models/*.cs` | | Message serializers | `ServerMode/DotnetTest/IPC/Serializers/*.cs` | -| Host connection / handshake / control channel | `ServerMode/DotnetTest/DotnetTestConnection.cs` | +| Host connection / handshake / control channel / transport dispatch | `ServerMode/DotnetTest/DotnetTestConnection.cs` | | Host data consumer (state → message mapping) | `ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs` | | Shared-source manifest (vendored to dotnet/sdk) | `ServerMode/DotnetTest/DotnetTestProtocolContract.props` | | Black-box protocol reference / tests | `test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/*`, `test/UnitTests/Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests/*` | + +--- + +## 15. WebSocket transport + +> [!NOTE] +> This section covers the **transport bootstrap** for the WebSocket alternative to the named pipe. The +> wire protocol carried over it (framing, serializers, handshake, message catalog, versioning) is exactly +> what §4-§10 already describe - nothing in this section changes a single byte on the wire. + +### 15.1 Why a second transport exists + +`System.IO.Pipes` (and therefore the entire transport described in §3) is unavailable on `browser-wasm` +(and `wasi-wasm`): there is no OS-level named-pipe primitive to open. Before this transport existed, the +SDK had no way to run a browser-wasm test application through the live `dotnet test` pipe protocol at all +and had to fall back to a degraded, standalone launch mode. The WebSocket transport gives `dotnet test` a +bootstrap path that works on any runtime with a WebSocket implementation, so the *same* wire protocol +(same serializers, same handshake, same message catalog) can be used everywhere. + +Protocol and transport are deliberately decoupled: `DotnetTestConnection` talks to an `IClient` (a small +connect/request-reply abstraction implemented identically in shape by `NamedPipeClient` and +`DotnetTestWebSocketClient`), and the shared framing in `NamedPipeConnectionBase` operates on a plain +`Stream` rather than a `PipeStream` specifically. Only `NamedPipeClient`'s pipe-specific behavior (pipe +naming, `WaitForPipeDrain`) stays isolated to the named-pipe implementation. + +### 15.2 Activation + +```text + --server dotnettestcli --dotnet-test-transport websocket \ + --dotnet-test-websocket-endpoint --dotnet-test-websocket-token [other options] +``` + +- `--dotnet-test-transport websocket` selects this transport. Omitting `--dotnet-test-transport` (or + passing `--dotnet-test-transport pipe`) keeps the named-pipe transport (§2, §3), which remains the + default for exact backward compatibility. +- `--dotnet-test-websocket-endpoint` takes the fully-resolved `ws://` (or `wss://`) URI the SDK/gateway is + already listening on - the test host is always the one that *initiates* the outbound connection, exactly + mirroring the named-pipe transport where the SDK creates the pipe and the host connects out to it. This + matters specifically for `browser-wasm`: the page/test host runs inside the browser sandbox and can only + make outbound connections; it cannot accept inbound ones. +- `--dotnet-test-websocket-token` takes a per-run opaque secret the SDK generated for this connection (see + §15.4). +- All three options are hidden and built-in, like `--dotnet-test-pipe`. +- Command-line validation (`PlatformCommandLineProvider.ValidateCommandLineOptionsAsync`) rejects + impossible or incomplete combinations before any connection is attempted: the named-pipe transport on + `browser-wasm`/`wasi-wasm`, `--dotnet-test-transport websocket` without both endpoint and token, + specifying both a pipe and a WebSocket transport, or WebSocket-only options without + `--dotnet-test-transport websocket`. `wasi-wasm` currently has **no** working transport at all (see + §15.6) and is rejected regardless of which transport was requested. + +### 15.3 Framing over WebSocket + +Every `NamedPipeConnectionBase.WriteMessageAsync` call writes one already-assembled frame (4-byte length + +4-byte serializer ID + body) in a single `Stream.WriteAsync`. The WebSocket adapters +(`ClientWebSocketDuplexStream` for non-browser runtimes, `BrowserWebSocketDuplexStream` for `browser-wasm`) +map that 1:1 to one **binary** WebSocket message per frame (`endOfMessage: true`). Reads are treated as a +plain byte stream - consecutive receives are handed back verbatim and buffered across calls - rather than +relying on WebSocket message boundaries, so the adapters stay correct regardless of how a given frame is +fragmented on the wire by the peer or an intermediary. + +`System.Net.WebSockets.ClientWebSocket` throws `PlatformNotSupportedException` on `browser-wasm`, so +`browser-wasm` uses a dedicated adapter that talks to the browser's native `WebSocket` object through +`[JSImport]`/`[JSExport]` JS interop (the same pattern `OutputDevice.BrowserOutputDevice` already uses for +`console.*`). The companion JS module is embedded as a string constant and imported via a `data:` URL, so +no changes to the generated wasm bootstrap or published asset set are required. + +### 15.4 Authentication and security + +There is no OS-level ACL equivalent to `PipeOptions.CurrentUserOnly` for a TCP/WebSocket endpoint, so the +transport authenticates every connection explicitly: + +- The SDK generates a per-run opaque token and passes it via `--dotnet-test-websocket-token`. +- The test host appends it to the connection URI as a query-string parameter (e.g. + `?dotnetTestToken=`) before connecting - see `DotnetTestWebSocketClient.BuildAuthenticatedUri`. + This is deliberate, not a workaround: the browser's native `WebSocket` constructor only accepts a URL and + an optional subprotocol list, so it **cannot** set an `Authorization` header (or any other custom + header) on the upgrade handshake. A query-string token is the same approach ASP.NET Core SignalR uses + for its WebSocket transport for the identical reason. +- **CORS is not authentication and must not be relied on as one.** CORS governs which browser *origins* may + *read* a cross-origin response; it says nothing about which *process* may *open* a WebSocket connection + to a loopback port in the first place. Any local process that can reach the port can attempt the + handshake, so the token is the actual access check, not a defense-in-depth extra. +- The SDK is expected to bind the listener to loopback (`127.0.0.1`/`::1`) only and to reject connections + whose token does not match the one it generated for that run/endpoint. +- **Never log the authenticated URI (or the token) verbatim.** Diagnostics should log only the endpoint's + host/port/path, never the query string. + +### 15.5 Handshake capability signal + +The handshake (§8) gained one additive property, `Transport` (ID 16, `HandshakeMessagePropertyNames.Transport`), +always sent by the host as `NamedPipe` or `WebSocket` (`HandshakeMessageTransportNames`). It exists purely +for diagnostics and future negotiation - the wire protocol itself is identical either way - so an older SDK +that does not look at it is entirely unaffected. `ProtocolConstants.SupportedVersions` was bumped to +include `1.5.0` alongside it, following the same convention as every other additive capability in §10. + +### 15.6 Known gaps and follow-ups (out of scope here) + +- **Reverse server-control channel (§12) is named-pipe-only.** The SDK advertises + `ServerControlPipeName` as a plain OS pipe name regardless of which transport carried the handshake. + `DotnetTestConnection` only opens the reverse channel when the current runtime supports named pipes, so + on `browser-wasm` (and `wasi-wasm`) server-initiated cancellation (`--timeout`, + `--maximum-failed-tests`, ...) simply stays disabled - the same graceful degradation already used when an + older SDK never advertises the pipe at all. A WebSocket-based (or transport-agnostic) reverse control + channel is a natural follow-up. +- **`wasi-wasm` has no transport yet.** It cannot use named pipes (no `System.IO.Pipes` support) and, as of + this writing, has neither a working `System.Net.WebSockets.ClientWebSocket` implementation nor an + established JS-interop equivalent in this repo (unlike `browser-wasm`, `wasi-wasm` has no browser/JS host + to interop with in the first place). Command-line validation rejects both transports on `wasi-wasm` + outright with an actionable error rather than silently falling back to a degraded mode. A `wasi-wasm` + transport (e.g. once/if a WASI sockets story matures in the .NET runtime) is a separate follow-up. +- **stdio was considered and deliberately not implemented.** Multiplexing the binary dotnettestcli protocol + onto the same stdio streams a test host also uses for its own console output (and that other extensions + may write to) would require either a second framing layer on top of the existing one or careful + interleaving that risks corrupting either stream. Rather than ship that as a bolted-on special case, it + is left as a candidate for a future, separately-designed transport if a concrete need arises. +- **The SDK side of this transport (loopback listener/gateway, token generation and validation) is not part + of this repository.** This document only specifies what the MTP-side client requires from that gateway; + see the coordinating `dotnet/sdk` change for the server implementation. diff --git a/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Shipped.txt b/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Shipped.txt index d25ba56360..64cc963a90 100644 --- a/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Shipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Shipped.txt @@ -278,8 +278,6 @@ Microsoft.Testing.Platform.IPC.NamedPipeClient.RequestReplyAsync void Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.NamedPipeConnectionBase() -> void -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.Testing.Platform.IPC.NamedPipeServer Microsoft.Testing.Platform.IPC.NamedPipeServer.Dispose() -> void Microsoft.Testing.Platform.IPC.NamedPipeServer.DisposeAsync() -> System.Threading.Tasks.ValueTask diff --git a/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Unshipped.txt index 5a42e4a96e..8e634436a1 100644 --- a/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Unshipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Unshipped.txt @@ -15,3 +15,5 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action! writeItem) -> void const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! diff --git a/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Shipped.txt b/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Shipped.txt index bdca6e9573..65e8a32bae 100644 --- a/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Shipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Shipped.txt @@ -270,8 +270,6 @@ Microsoft.Testing.Platform.IPC.NamedPipeClient.RequestReplyAsync void Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.NamedPipeConnectionBase() -> void -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.Testing.Platform.IPC.NamedPipeServer Microsoft.Testing.Platform.IPC.NamedPipeServer.Dispose() -> void Microsoft.Testing.Platform.IPC.NamedPipeServer.DisposeAsync() -> System.Threading.Tasks.ValueTask diff --git a/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Unshipped.txt index eab62e52eb..ef61d86935 100644 --- a/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Unshipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.MSBuild/InternalAPI.Unshipped.txt @@ -14,3 +14,5 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action! writeItem) -> void const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! diff --git a/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Shipped.txt b/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Shipped.txt index 3f8322ec87..843494da5d 100644 --- a/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Shipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Shipped.txt @@ -276,8 +276,6 @@ Microsoft.Testing.Platform.IPC.NamedPipeClient.RequestReplyAsync void Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.NamedPipeConnectionBase() -> void -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.Testing.Platform.IPC.NamedPipeServer Microsoft.Testing.Platform.IPC.NamedPipeServer.Dispose() -> void Microsoft.Testing.Platform.IPC.NamedPipeServer.DisposeAsync() -> System.Threading.Tasks.ValueTask diff --git a/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Unshipped.txt index 64777f2fb2..18fbae2d94 100644 --- a/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Unshipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Unshipped.txt @@ -18,3 +18,5 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action! writeItem) -> void const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! diff --git a/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Shipped.txt b/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Shipped.txt index a6ff4d635d..9cd99af227 100644 --- a/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Shipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Shipped.txt @@ -473,8 +473,6 @@ Microsoft.Testing.Platform.IPC.NamedPipeClient.RequestReplyAsync void Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.NamedPipeConnectionBase() -> void -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.Testing.Platform.IPC.NamedPipeServer Microsoft.Testing.Platform.IPC.NamedPipeServer.Dispose() -> void Microsoft.Testing.Platform.IPC.NamedPipeServer.DisposeAsync() -> System.Threading.Tasks.ValueTask diff --git a/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt index ef54e98ea1..1431eb7694 100644 --- a/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt +++ b/src/Platform/Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt @@ -68,3 +68,5 @@ Microsoft.Testing.Extensions.MergeOutputFileHelper static Microsoft.Testing.Extensions.MergeOutputFileHelper.BuildCaseFoldedProbePath(string! directory, string! probeFileName) -> string! static Microsoft.Testing.Extensions.MergeOutputFileHelper.EnsureOutputDoesNotAliasInput(System.Collections.Generic.IReadOnlyList! inputPaths, string! outputPath) -> void static Microsoft.Testing.Extensions.MergeOutputFileHelper.WriteViaTemporarySiblingAsync(string! outputPath, System.Func! writeToTempAsync) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs index 2306aae0dd..fbfbbea09b 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs @@ -27,6 +27,7 @@ internal sealed class PlatformCommandLineProvider : CommandLineOptionsProviderBa private static readonly string SupportedDiscoverTestsValues = $"'{DiscoverTestsTextArgument}', '{DiscoverTestsJsonArgument}'"; private static readonly string SupportedServerProtocolValues = $"'{JsonRpcProtocolName}', '{DotnetTestCliProtocolName}'"; + private static readonly string SupportedDotNetTestTransportValues = $"'{DotNetTestTransportPipeArgument}', '{DotNetTestTransportWebSocketArgument}'"; public const string ResultDirectoryOptionKey = "results-directory"; public const string IgnoreExitCodeOptionKey = "ignore-exit-code"; public const string MinimumExpectedTestsOptionKey = "minimum-expected-tests"; @@ -46,6 +47,20 @@ internal sealed class PlatformCommandLineProvider : CommandLineOptionsProviderBa public const string DotNetTestPipeOptionKey = "dotnet-test-pipe"; public const string DotnetTestCliProtocolName = "dotnettestcli"; + // Pre-launch transport selection for the 'dotnet test' pipe protocol (a.k.a. dotnettestcli). The wire + // protocol (message/serializer/version contract) is transport-neutral; this option only selects which + // duplex channel carries it. 'pipe' (the default, implied when only '--dotnet-test-pipe' is given) keeps + // the existing System.IO.Pipes behavior byte-for-byte. 'websocket' is required on runtimes that cannot use + // named pipes (browser-wasm) and is opt-in elsewhere. + public const string DotNetTestTransportOptionKey = "dotnet-test-transport"; + public const string DotNetTestTransportPipeArgument = "pipe"; + public const string DotNetTestTransportWebSocketArgument = "websocket"; + + // WebSocket-transport-specific endpoint/auth options. Both are required together with + // '--dotnet-test-transport websocket' and mutually exclusive with '--dotnet-test-pipe'. + public const string DotNetTestWebSocketEndpointOptionKey = "dotnet-test-websocket-endpoint"; + public const string DotNetTestWebSocketTokenOptionKey = "dotnet-test-websocket-token"; + private static readonly string[] VerbosityOptions = ["Trace", "Debug", "Information", "Warning", "Error", "Critical"]; private static readonly string SupportedZeroTestsPolicyValues = $"'{ZeroTestsPolicyStrictArgument}', '{ZeroTestsPolicyAllowSkippedArgument}'"; @@ -81,7 +96,10 @@ internal sealed class PlatformCommandLineProvider : CommandLineOptionsProviderBa new(SkipBuildersNumberCheckOptionKey, PlatformResources.PlatformCommandLineSkipBuildersNumberCheckOptionDescription, ArgumentArity.Zero, true, isBuiltIn: true), new(NoBannerOptionKey, PlatformResources.PlatformCommandLineNoBannerOptionDescription, ArgumentArity.ZeroOrOne, true, isBuiltIn: true), new(TestHostControllerPIDOptionKey, PlatformResources.PlatformCommandLineTestHostControllerPIDOptionDescription, ArgumentArity.ZeroOrOne, true, isBuiltIn: true), - new(DotNetTestPipeOptionKey, PlatformResources.PlatformCommandLineDotnetTestPipe, ArgumentArity.ExactlyOne, true, isBuiltIn: true) + new(DotNetTestPipeOptionKey, PlatformResources.PlatformCommandLineDotnetTestPipe, ArgumentArity.ExactlyOne, true, isBuiltIn: true), + new(DotNetTestTransportOptionKey, PlatformResources.PlatformCommandLineDotnetTestTransportOptionDescription, ArgumentArity.ExactlyOne, true, isBuiltIn: true), + new(DotNetTestWebSocketEndpointOptionKey, PlatformResources.PlatformCommandLineDotnetTestWebSocketEndpointOptionDescription, ArgumentArity.ExactlyOne, true, isBuiltIn: true), + new(DotNetTestWebSocketTokenOptionKey, PlatformResources.PlatformCommandLineDotnetTestWebSocketTokenOptionDescription, ArgumentArity.ExactlyOne, true, isBuiltIn: true), ]; public PlatformCommandLineProvider() @@ -121,6 +139,14 @@ public override Task ValidateOptionArgumentsAsync(CommandLineO return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.PlatformCommandLineServerInvalidArgument, arguments[0], SupportedServerProtocolValues)); } + if (commandOption.Name == DotNetTestTransportOptionKey + && arguments.Length == 1 + && !DotNetTestTransportPipeArgument.Equals(arguments[0], StringComparison.OrdinalIgnoreCase) + && !DotNetTestTransportWebSocketArgument.Equals(arguments[0], StringComparison.OrdinalIgnoreCase)) + { + return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.PlatformCommandLineDotnetTestTransportInvalidArgument, arguments[0], SupportedDotNetTestTransportValues)); + } + if (commandOption.Name == ClientPortOptionKey && (!int.TryParse(arguments[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out int port) || port < System.Net.IPEndPoint.MinPort @@ -234,16 +260,73 @@ public override Task ValidateCommandLineOptionsAsync(ICommandL return ValidationResult.InvalidTask(PlatformResources.OnlyOneFilterSupported); } - // The '--server dotnettestcli' protocol path requires '--dotnet-test-pipe' to connect to the - // dotnet test pipe. Without it, the dotnet test connection silently never activates and the - // application falls back to console mode, leading to confusing behavior. Both options are - // internal and are expected to be passed together by 'dotnet test'. + // The '--server dotnettestcli' protocol path requires exactly one pre-launch transport to carry the + // (transport-neutral) wire protocol: either the legacy named pipe ('--dotnet-test-pipe', the default, + // implied whenever it alone is given) or an explicit WebSocket transport ('--dotnet-test-transport + // websocket' plus its endpoint/token). Without one of these, the dotnet test connection silently never + // activates and the application falls back to console mode, leading to confusing behavior. All of these + // options are internal and are expected to be passed together by 'dotnet test'. if (commandLineOptions.TryGetOptionArgumentList(ServerOptionKey, out string[]? serverProtocolArgs) && serverProtocolArgs is { Length: 1 } - && DotnetTestCliProtocolName.Equals(serverProtocolArgs[0], StringComparison.OrdinalIgnoreCase) - && !commandLineOptions.IsOptionSet(DotNetTestPipeOptionKey)) + && DotnetTestCliProtocolName.Equals(serverProtocolArgs[0], StringComparison.OrdinalIgnoreCase)) { - return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.PlatformCommandLineDotnetTestCliRequiresPipe, DotnetTestCliProtocolName, DotNetTestPipeOptionKey)); + bool hasPipe = commandLineOptions.IsOptionSet(DotNetTestPipeOptionKey); + bool hasTransportOption = commandLineOptions.TryGetOptionArgumentList(DotNetTestTransportOptionKey, out string[]? transportArgs) + && transportArgs is { Length: 1 }; + bool isWebSocketTransport = hasTransportOption && DotNetTestTransportWebSocketArgument.Equals(transportArgs![0], StringComparison.OrdinalIgnoreCase); + bool hasEndpoint = commandLineOptions.IsOptionSet(DotNetTestWebSocketEndpointOptionKey); + bool hasToken = commandLineOptions.IsOptionSet(DotNetTestWebSocketTokenOptionKey); + + // 1. Conflict: a pipe name together with anything WebSocket-shaped (explicit websocket transport, an + // endpoint, or a token) - the two transports are mutually exclusive. + if (hasPipe && (isWebSocketTransport || hasEndpoint || hasToken)) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLineDotnetTestTransportConflict); + } + + // 2. WebSocket-only options given without selecting the WebSocket transport, and no pipe either: the + // more specific and actionable message ("these options require --dotnet-test-transport websocket") + // beats the generic "no transport selected" message from step 3 below. + if (!hasPipe && !isWebSocketTransport && (hasEndpoint || hasToken)) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLineDotnetTestWebSocketOptionsRequireTransport); + } + + // 3. Nothing selects a transport at all (covers: no options given, or --dotnet-test-transport pipe + // given explicitly without the required --dotnet-test-pipe name). + if (!hasPipe && !isWebSocketTransport) + { + return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.PlatformCommandLineDotnetTestCliRequiresPipe, DotnetTestCliProtocolName, DotNetTestPipeOptionKey)); + } + + // 4. WebSocket transport selected (or implied) but incomplete. + if (isWebSocketTransport && (!hasEndpoint || !hasToken)) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken); + } + + // Reject impossible transport/runtime combinations as early as possible (before we ever try to + // construct a NamedPipeClient, which would throw PlatformNotSupportedException deep inside the + // connection bootstrap). System.IO.Pipes is not available on either single-threaded wasm runtime. + if (hasPipe && OperatingSystem.IsBrowser()) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLinePipeTransportNotSupportedOnBrowser); + } + + if (hasPipe && OperatingSystem.IsWasi()) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLinePipeTransportNotSupportedOnWasi); + } + + // The WebSocket transport is implemented for browser-wasm (via JS interop) and for regular + // (non-wasm) runtimes (via System.Net.WebSockets.ClientWebSocket). wasi-wasm has neither a + // ClientWebSocket implementation nor an established JS-interop equivalent in this repo, so it is + // not yet supported by any transport; fail fast with an actionable message instead of silently + // falling back to console mode. + if (isWebSocketTransport && OperatingSystem.IsWasi()) + { + return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLineWebSocketTransportNotSupportedOnWasi); + } } if (commandLineOptions.IsOptionSet(DiagnosticFileLoggerSynchronousWriteOptionKey)) diff --git a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeConnectionBase.cs b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeConnectionBase.cs index b183ca3418..31c32d0c7d 100644 --- a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeConnectionBase.cs +++ b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeConnectionBase.cs @@ -14,9 +14,11 @@ namespace Microsoft.Testing.Platform.IPC; -// Named-pipe framing/transport shared by NamedPipeServer and NamedPipeClient. This is deliberately NOT part of the -// source-shared serializer registry (NamedPipeBase): the transport differs per repo (e.g. dotnet/sdk inlines its own -// read/write loop), so only the registry + serializers are shared. This type stays local to Microsoft.Testing.Platform. +// Duplex-stream framing/transport shared by NamedPipeServer, NamedPipeClient, and DotnetTestWebSocketClient. This is +// deliberately NOT part of the source-shared serializer registry (NamedPipeBase): the transport differs per repo +// (e.g. dotnet/sdk inlines its own read/write loop), so only the registry + serializers are shared. This type stays +// local to Microsoft.Testing.Platform. It operates on any duplex Stream (PipeStream, a WebSocket-backed Stream, ...); +// the only pipe-specific behavior (WaitForPipeDrain) is isolated behind an `is PipeStream` check. [Embedded] [SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "Disposal is delegated to subclasses via DisposeBuffers().")] internal abstract class NamedPipeConnectionBase : NamedPipeBase @@ -28,12 +30,15 @@ internal abstract class NamedPipeConnectionBase : NamedPipeBase /// /// Serializes using , frames it with a /// 4-byte size header and 4-byte serializer-ID prefix, writes the frame to , - /// flushes, and (on Windows) waits for the pipe to drain. + /// flushes, and (on Windows, when is a named pipe) waits for the pipe to drain. /// -#if !MTP_MSBUILD_TASKS - [UnsupportedOSPlatform("browser")] -#endif - protected async Task WriteMessageAsync(PipeStream stream, INamedPipeSerializer serializer, object message, CancellationToken cancellationToken) + /// + /// This method is transport-neutral: may be a (the + /// named-pipe transport) or any other duplex (e.g. a WebSocket-backed duplex stream). + /// The only pipe-specific behavior - - is isolated behind an + /// is PipeStream check so it only ever runs for the named-pipe transport. + /// + protected async Task WriteMessageAsync(Stream stream, INamedPipeSerializer serializer, object message, CancellationToken cancellationToken) { // Serialize the message body _serializationBuffer.Position = 0; @@ -103,9 +108,9 @@ protected async Task WriteMessageAsync(PipeStream stream, INamedPipeSerializer s await stream.WriteAsync(_messageBuffer.GetBuffer(), 0, (int)_messageBuffer.Position, cancellationToken).ConfigureAwait(false); #endif await stream.FlushAsync(cancellationToken).ConfigureAwait(false); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (stream is PipeStream pipeStream && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - stream.WaitForPipeDrain(); + pipeStream.WaitForPipeDrain(); } } finally @@ -119,10 +124,10 @@ protected async Task WriteMessageAsync(PipeStream stream, INamedPipeSerializer s /// Reads one complete framed message from , deserializes it, and returns /// the result. Returns when the stream reaches EOF (peer disconnected). /// -#if !MTP_MSBUILD_TASKS - [UnsupportedOSPlatform("browser")] -#endif - protected async Task ReadNextMessageAsync(PipeStream stream, CancellationToken cancellationToken) + /// + /// Transport-neutral: see the remarks on . + /// + protected async Task ReadNextMessageAsync(Stream stream, CancellationToken cancellationToken) { _messageBuffer.Position = 0; diff --git a/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt b/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt index 227095275f..4eea96cb68 100644 --- a/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt +++ b/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt @@ -1318,8 +1318,6 @@ Microsoft.Testing.Platform.IPC.NamedPipeClient.RequestReplyAsync void Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.NamedPipeConnectionBase() -> void -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! -Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Microsoft.Testing.Platform.IPC.NamedPipeServer Microsoft.Testing.Platform.IPC.NamedPipeServer.Dispose() -> void Microsoft.Testing.Platform.IPC.NamedPipeServer.NamedPipeServer(Microsoft.Testing.Platform.IPC.PipeNameDescription! pipeNameDescription, System.Func!>! callback, Microsoft.Testing.Platform.Helpers.IEnvironment! environment, Microsoft.Testing.Platform.Logging.ILogger! logger, Microsoft.Testing.Platform.Helpers.ITask! task, int maxNumberOfServerInstances, System.Threading.CancellationToken cancellationToken) -> void diff --git a/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt index 103558d233..b6ebe63ddd 100644 --- a/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt +++ b/src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt @@ -195,3 +195,43 @@ Microsoft.Testing.Platform.OutputDevice.Terminal.TerminalTestReporter.TerminalTe Microsoft.Testing.Platform.OutputDevice.Terminal.TestProgressStateAwareTerminal.TestProgressStateAwareTerminal(Microsoft.Testing.Platform.OutputDevice.Terminal.ITerminal! terminal, System.Func! showProgress, Microsoft.Testing.Platform.OutputDevice.Terminal.IProgressRenderer! renderer, Microsoft.Testing.Platform.Logging.ILogger! logger) -> void Microsoft.Testing.Platform.ServerMode.ServerModeManager.MessageHandlerFactory.MessageHandlerFactory(string! host, int port, Microsoft.Testing.Platform.OutputDevice.IOutputDevice! outputDevice, Microsoft.Testing.Platform.Logging.ILogger! logger) -> void Microsoft.Testing.Platform.ServerMode.TcpMessageHandler.TcpMessageHandler(System.Net.Sockets.TcpClient! client, System.IO.Stream! clientToServerStream, System.IO.Stream! serverToClientStream, Microsoft.Testing.Platform.ServerMode.IMessageFormatter! formatter, Microsoft.Testing.Platform.Logging.ILogger! logger) -> void +const Microsoft.Testing.Platform.CommandLine.PlatformCommandLineProvider.DotNetTestTransportOptionKey = "dotnet-test-transport" -> string! +const Microsoft.Testing.Platform.CommandLine.PlatformCommandLineProvider.DotNetTestTransportPipeArgument = "pipe" -> string! +const Microsoft.Testing.Platform.CommandLine.PlatformCommandLineProvider.DotNetTestTransportWebSocketArgument = "websocket" -> string! +const Microsoft.Testing.Platform.CommandLine.PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey = "dotnet-test-websocket-endpoint" -> string! +const Microsoft.Testing.Platform.CommandLine.PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey = "dotnet-test-websocket-token" -> string! +const Microsoft.Testing.Platform.IPC.HandshakeMessagePropertyNames.Transport = 16 -> byte +const Microsoft.Testing.Platform.IPC.HandshakeMessageTransportNames.NamedPipe = "NamedPipe" -> string! +const Microsoft.Testing.Platform.IPC.HandshakeMessageTransportNames.WebSocket = "WebSocket" -> string! +const Microsoft.Testing.Platform.IPC.ProtocolConstants.SupportedVersions = "1.0.0;1.1.0;1.2.0;1.3.0;1.4.0;1.5.0" -> string! +Microsoft.Testing.Platform.DotnetTestTransportKind +Microsoft.Testing.Platform.DotnetTestTransportKind.NamedPipe = 0 -> Microsoft.Testing.Platform.DotnetTestTransportKind +Microsoft.Testing.Platform.DotnetTestTransportKind.WebSocket = 1 -> Microsoft.Testing.Platform.DotnetTestTransportKind +Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream +Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.ClientWebSocketDuplexStream(System.Net.WebSockets.WebSocket! webSocket) -> void +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.ConnectAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.Dispose() -> void +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.DotnetTestWebSocketClient(System.Uri! endpoint, string! authToken, Microsoft.Testing.Platform.Helpers.IEnvironment! environment, bool exitProcessOnConnectionLoss) -> void +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.DotnetTestWebSocketClient(System.Uri! endpoint, string! authToken, Microsoft.Testing.Platform.Helpers.IEnvironment! environment) -> void +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.IsConnected.get -> bool +Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.RequestReplyAsync(TRequest request, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.HandshakeMessageTransportNames +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.CanRead.get -> bool +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.CanSeek.get -> bool +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.CanWrite.get -> bool +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Flush() -> void +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Length.get -> long +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Position.get -> long +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Position.set -> void +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Read(byte[]! buffer, int offset, int count) -> int +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.ReadAsync(byte[]! buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Seek(long offset, System.IO.SeekOrigin origin) -> long +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.SetLength(long value) -> void +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.Write(byte[]! buffer, int offset, int count) -> void +override Microsoft.Testing.Platform.IPC.ClientWebSocketDuplexStream.WriteAsync(byte[]! buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! +static Microsoft.Testing.Platform.DotnetTestHelper.TryGetDotnetTestTransport(this Microsoft.Testing.Platform.CommandLine.CommandLineHandler! commandLineHandler, out Microsoft.Testing.Platform.DotnetTestTransportKind transport) -> bool +static Microsoft.Testing.Platform.IPC.DotnetTestWebSocketClient.BuildAuthenticatedUri(System.Uri! endpoint, string! token) -> System.Uri! diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.cs b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.cs index b06cd4e0c0..3a35bfe342 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.cs +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.cs @@ -53,6 +53,20 @@ internal static partial class PlatformResources internal static string @PlatformCommandLineDotnetTestCliRequiresPipe => GetResourceString("PlatformCommandLineDotnetTestCliRequiresPipe"); + internal static string @PlatformCommandLineDotnetTestTransportInvalidArgument => GetResourceString("PlatformCommandLineDotnetTestTransportInvalidArgument"); + + internal static string @PlatformCommandLineDotnetTestTransportConflict => GetResourceString("PlatformCommandLineDotnetTestTransportConflict"); + + internal static string @PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken => GetResourceString("PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken"); + + internal static string @PlatformCommandLineDotnetTestWebSocketOptionsRequireTransport => GetResourceString("PlatformCommandLineDotnetTestWebSocketOptionsRequireTransport"); + + internal static string @PlatformCommandLinePipeTransportNotSupportedOnBrowser => GetResourceString("PlatformCommandLinePipeTransportNotSupportedOnBrowser"); + + internal static string @PlatformCommandLinePipeTransportNotSupportedOnWasi => GetResourceString("PlatformCommandLinePipeTransportNotSupportedOnWasi"); + + internal static string @PlatformCommandLineWebSocketTransportNotSupportedOnWasi => GetResourceString("PlatformCommandLineWebSocketTransportNotSupportedOnWasi"); + internal static string @PlatformCommandLineExitOnProcessExitSingleArgument => GetResourceString("PlatformCommandLineExitOnProcessExitSingleArgument"); internal static string @PlatformCommandLineDiagnosticOptionIsMissing => GetResourceString("PlatformCommandLineDiagnosticOptionIsMissing"); diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx index e89aed2514..077ce30f59 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx @@ -607,6 +607,46 @@ The default is TestResults in the directory that contains the test application.< dotnet test pipe. {Locked="dotnet test"} + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Use a tree filter to filter down the tests to execute diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf index bd7bba562c..5ec073178c 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf @@ -626,6 +626,41 @@ Volitelně přijímá hodnotu „text“ (výchozí výstup čitelný pro člov dotnet test kanál. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Volitelně přijímá hodnotu „text“ (výchozí výstup čitelný pro člov Nezobrazovat úvodní banner, zprávu o autorských právech ani banner telemetrie + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Zadejte port serveru. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Takes one argument as a time value with an explicit unit suffix. Accepted suffixes are 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', e.g. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Neplatná hodnota {0} pro parametr --zero-tests-policy. Platné hodnoty jsou {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf index 617918e2f8..b370850f7a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf @@ -626,6 +626,41 @@ Akzeptiert optional „text“ (die standardmäsige lesbare Ausgabe) oder „jso dotnet test pipe. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Akzeptiert optional „text“ (die standardmäsige lesbare Ausgabe) oder „jso Zeigen Sie das Startbanner, die Copyrightmeldung oder das Telemetriebanner nicht an. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Geben Sie den Port des Servers an. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Verwendet ein Argument als Zeitwert mit einem expliziten Einheitensuffix. Akzeptierte Suffixe sind 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', z. B. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Ungültiger Wert „{0}“ für „--zero-tests-policy“. Gültige Werte sind „{1}“. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf index e0960d9b39..dada9c1619 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf @@ -626,6 +626,41 @@ Opcionalmente, acepta "text" (la salida legible por el usuario predeterminada) o canalización de dotnet test {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Opcionalmente, acepta "text" (la salida legible por el usuario predeterminada) o No muestre el banner de inicio, el mensaje de copyright o el banner de telemetría. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Especifique el puerto del servidor. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Takes one argument as a time value with an explicit unit suffix. Accepted suffixes are 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', e.g. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Valor no válido "{0}" para "--zero-tests-policy". Los valores válidos son {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf index 13f2c0a0c7..4152875b8c 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf @@ -626,6 +626,41 @@ Accepte éventuellement « text » (sortie lisible par l’humain par défaut) canal de dotnet test. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Accepte éventuellement « text » (sortie lisible par l’humain par défaut) Ne pas afficher la bannière de démarrage, le message de copyright ou la bannière de télémétrie. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Spécifier le port du serveur. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Prend un argument correspondant à une valeur de temps avec un suffixe d’unité explicite. Les suffixes acceptés sont 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)' et 'd'/'day(s)', par exemple '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Valeur non valide « {0} » pour « --zero-tests-policy ». Les valeurs valides sont {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf index d1d0ac4313..0be73e12da 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf @@ -626,6 +626,41 @@ Facoltativamente accetta ''text'' (output leggibile predefinito) o ''json'' per pipe di dotnet test. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Facoltativamente accetta ''text'' (output leggibile predefinito) o ''json'' per Non visualizzare il banner di avvio, il messaggio di copyright o il banner di telemetria. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Specifica la porta del server. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Accetta un argomento come valore di ora con un suffisso di unità esplicito. I suffissi accettati sono 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)' e 'd'/'day(s)', ad esempio '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Valore ''{0}'' non valido per ''--zero-tests-policy''. I valori validi sono {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf index 04980f3e0f..d1d03b4668 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test パイプ。 {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -698,6 +733,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print スタートアップ バナー、著作権メッセージ、テレメトリ バナーは表示しないでください。 + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. サーバーのポートを指定します。 @@ -759,6 +804,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix 明示的な単位サフィックスを持つ時間値を 1 つ、引数として指定します。使用可能なサフィックスは、'ms'/'mil(s)'/'millisecond(s)'、's'/'sec(s)'/'second(s)'、'm'/'min(s)'/'minute(s)'、'h'/'hour(s)'、'd'/'day(s)' です (例: '500ms'、'5400s'、'90m'、'1.5h'、'1d')。 {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. '--zero-tests-policy' の値 '{0}' は無効です。有効な値は {1} です。 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf index b569dd3ac1..109e45a522 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test 파이프. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print 시작 배너, 저작권 메시지 또는 원격 분석 배너를 표시하지 마세요. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. 서버의 포트를 지정합니다. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix 명시적 단위 접미사가 포함된 시간 값을 하나의 인수로 입력해야 합니다. 허용되는 접미사는 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', 'd'/'day(s)'입니다. (예: '500ms', '5400s', '90m', '1.5h', '1d') {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. '--zero-tests-policy'에 잘못된 값 '{0}'이(가) 지정되었습니다. 유효한 값은 {1}입니다. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf index 6c871df623..9ff303d7b1 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf @@ -626,6 +626,41 @@ Opcjonalnie akceptuje „text” (domyślne dane wyjściowe czytelne dla człowi potok dotnet test. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Opcjonalnie akceptuje „text” (domyślne dane wyjściowe czytelne dla człowi Nie wyświetlaj baneru startowego, komunikatu o prawach autorskich ani transparentu telemetrii. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Określ port serwera. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Takes one argument as a time value with an explicit unit suffix. Accepted suffixes are 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', e.g. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Nieprawidłowa wartość „{0}” d; „--zero-tests-policy”. Prawidłowe wartości to {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf index d0c2bde469..beea70a70b 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf @@ -626,6 +626,41 @@ Opcionalmente, aceita 'text' (a saída legível por humanos padrão) ou 'json' p pipe de dotnet test. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Opcionalmente, aceita 'text' (a saída legível por humanos padrão) ou 'json' p Não exiba a faixa de inicialização, a mensagem de direitos autorais ou a faixa de telemetria. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Especifique a porta do servidor. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Recebe um argumento como valor temporal, com um sufixo de unidade explícito. Os sufixos aceitos são 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)' e 'd'/'day(s)'. Por exemplo: '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Valor inválido "{0}" para "--zero-tests-policy". Os valores válidos são {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf index 076346dd4a..16d77727df 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test канал. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print Не отображать баннер запуска, сообщение об авторских правах и баннер телеметрии. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Укажите порт сервера. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Takes one argument as a time value with an explicit unit suffix. Accepted suffixes are 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', e.g. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. Недопустимое значение "{0}" для "--zero-tests-policy". Допустимые значения: {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf index fcad947c96..0591703956 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test kanalı. {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print Başlangıç başlığını, telif hakkı iletisini veya telemetri başlığını görüntülemez. + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. Sunucunun bağlantı noktasını belirtir. @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Açık bir birim soneki bulunan bir zaman değeri olarak bir bağımsız değişken alır. Kabul edilen sonekler: 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', ör. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. '--zero-tests-policy' için geçersiz değer '{0}'. Geçerli değerler {1}. diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf index 4b00eca074..a4a0b17644 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test 管道。 {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print 请勿显示启动横幅、版权信息或遥测横幅。 + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. 指定服务器的端口。 @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix Takes one argument as a time value with an explicit unit suffix. Accepted suffixes are 'ms'/'mil(s)'/'millisecond(s)', 's'/'sec(s)'/'second(s)', 'm'/'min(s)'/'minute(s)', 'h'/'hour(s)', and 'd'/'day(s)', e.g. '500ms', '5400s', '90m', '1.5h', '1d'. {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. "--zero-tests-policy" 的值“{0}”无效。有效值为 {1}。 diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf index 0e94b44533..aa6137808c 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf @@ -626,6 +626,41 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print dotnet test 管道。 {Locked="dotnet test"} + + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + '--dotnet-test-pipe' cannot be combined with '--dotnet-test-transport websocket', '--dotnet-test-websocket-endpoint', or '--dotnet-test-websocket-token'. Choose a single transport. + {Locked="--dotnet-test-pipe"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + '--dotnet-test-transport' received unexpected value '{0}'. Supported values are: {1}. + {0} is the unexpected transport value. {1} is the comma-separated list of supported transport values. {Locked="--dotnet-test-transport"} + + + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + Pre-launch transport used to carry the 'dotnet test' pipe protocol. The available values are 'pipe' and 'websocket'. Defaults to 'pipe' (implied whenever only '--dotnet-test-pipe' is specified). + {Locked="dotnet test"}{Locked="pipe"}{Locked="websocket"}{Locked="--dotnet-test-pipe"} + + + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + The WebSocket endpoint URI the test host connects to when '--dotnet-test-transport websocket' is selected. + {Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' require '--dotnet-test-transport websocket' to be specified. + {Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"}{Locked="--dotnet-test-transport websocket"} + + + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + '--dotnet-test-transport websocket' requires both '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' to be specified. + {Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + The per-run authentication token the test host presents when connecting via '--dotnet-test-transport websocket'. + {Locked="--dotnet-test-transport websocket"} + Invalid PID '{0}' {1} @@ -697,6 +732,16 @@ Optionally accepts 'text' (the default human-readable output) or 'json' to print 不要顯示啟動橫幅、著作權訊息或遙測橫幅。 + + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + The named-pipe transport for '--server dotnettestcli' is not supported when running on browser-wasm (System.IO.Pipes is unavailable). Use '--dotnet-test-transport websocket' with '--dotnet-test-websocket-endpoint' and '--dotnet-test-websocket-token' instead. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"}{Locked="--dotnet-test-transport websocket"}{Locked="--dotnet-test-websocket-endpoint"}{Locked="--dotnet-test-websocket-token"} + + + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + The named-pipe transport for '--server dotnettestcli' is not supported when running on wasi-wasm (System.IO.Pipes is unavailable). No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"}{Locked="System.IO.Pipes"} + Specify the port of the server. 指定伺服器的連接埠。 @@ -758,6 +803,11 @@ Takes one argument as a time value with an explicit unit suffix. Accepted suffix 採用一個引數做為具有明確單位後置詞的時間值。接受的後置詞為 'ms'/'mil(s)'/'millisecond(s)'、's'/'sec(s)'/'second(s)'、'm'/'min(s)'/'minute(s)'、'h'/'hour(s)' 和 'd'/'day(s)',例如 '500ms'、'5400s'、'90m'、'1.5h'、'1d'。 {Locked="'ms'"}{Locked="'mil(s)'"}{Locked="'millisecond(s)'"}{Locked="'s'"}{Locked="'sec(s)'"}{Locked="'second(s)'"}{Locked="'m'"}{Locked="'min(s)'"}{Locked="'minute(s)'"}{Locked="'h'"}{Locked="'hour(s)'"}{Locked="'d'"}{Locked="'day(s)'"}{Locked="'500ms'"}{Locked="'5400s'"}{Locked="'90m'"}{Locked="'1.5h'"}{Locked="'1d'"} + + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + The websocket transport for '--server dotnettestcli' is not supported when running on wasi-wasm. No transport is currently implemented for wasi-wasm. + {Locked="--server dotnettestcli"} + Invalid value '{0}' for '--zero-tests-policy'. Valid values are {1}. '--zero-tests-policy' 的無效值 '{0}'。有效的值為 {1}。 diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestConnection.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestConnection.cs index 8b67f24b08..f1ee33b48e 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestConnection.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestConnection.cs @@ -14,7 +14,6 @@ namespace Microsoft.Testing.Platform; -[UnsupportedOSPlatform("browser")] internal sealed class DotnetTestConnection : IPushOnlyProtocol, IDisposable { private readonly CommandLineHandler _commandLineHandler; @@ -23,9 +22,18 @@ internal sealed class DotnetTestConnection : IPushOnlyProtocol, IDisposable private readonly ITestApplicationCancellationTokenSource _cancellationTokenSource; private readonly ILogger _logger; - private NamedPipeClient? _dotnetTestPipeClient; + // The connected dotnettestcli transport - a NamedPipeClient (the default, System.IO.Pipes-based) or a + // DotnetTestWebSocketClient (required on browser-wasm; optional elsewhere). The wire protocol is identical + // over either; only the duplex channel underneath differs. See DotnetTestTransportKind. + private IClient? _transportClient; + private DotnetTestTransportKind? _transportKind; + // The reverse "server control" auxiliary channel is a NamedPipeClient regardless of the primary transport + // (see IsCompatibleProtocolAsync); it is only ever populated when IsServerControlChannelSupported is true, + // which already excludes browser/wasi. +#pragma warning disable CA1416 private NamedPipeClient? _serverControlPipeClient; +#pragma warning restore CA1416 private Task? _serverControlListenerTask; private CancellationTokenSource? _serverControlListenerCts; private string? _serverControlPipeName; @@ -53,17 +61,19 @@ public DotnetTestConnection(CommandLineHandler commandLineHandler, IEnvironment _logger = logger; } - public bool IsServerMode => _dotnetTestPipeClient?.IsConnected == true; + public bool IsServerMode => _transportClient?.IsConnected == true; public Task GetDataConsumerAsync() => Task.FromResult((IPushOnlyProtocolConsumer)new DotnetTestDataConsumer(this, _environment)); public async Task AfterCommonServiceSetupAsync() { - // If we are in server mode and the pipe name is provided - // then, we need to connect to the pipe server. + // If we are in server mode and a transport was selected, connect using it before anything else can run. + // PlatformCommandLineProvider.ValidateCommandLineOptionsAsync has already rejected impossible + // combinations (e.g. the named-pipe transport on browser-wasm/wasi-wasm, or conflicting/incomplete + // transport options), so by the time we get here exactly one well-formed transport is selected. if (_commandLineHandler.HasDotnetTestServerOption() && - _commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.DotNetTestPipeOptionKey, out string[]? arguments)) + _commandLineHandler.TryGetDotnetTestTransport(out DotnetTestTransportKind transport)) { // The execution id is used to identify the test execution // We are storing it as an env var so that it can be read by the test host, test host controller and the test host orchestrator @@ -73,16 +83,43 @@ public async Task AfterCommonServiceSetupAsync() _environment.SetEnvironmentVariable(EnvironmentVariableConstants.TESTINGPLATFORM_DOTNETTEST_EXECUTIONID, Guid.NewGuid().ToString("N")); } - _dotnetTestPipeClient = new(arguments[0], _environment); - _dotnetTestPipeClient.RegisterAllSerializers(); + // CreateNamedPipeClient is never reached on browser/wasi: command-line validation already rejects + // the named-pipe transport there (see PlatformCommandLineProvider.ValidateCommandLineOptionsAsync). +#pragma warning disable CA1416 + _transportClient = transport == DotnetTestTransportKind.WebSocket + ? CreateWebSocketClient() + : CreateNamedPipeClient(); +#pragma warning restore CA1416 + _transportKind = transport; - await _dotnetTestPipeClient.ConnectAsync(_cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await _transportClient.ConnectAsync(_cancellationTokenSource.CancellationToken).ConfigureAwait(false); } } + // Isolated in its own method (rather than inline in AfterCommonServiceSetupAsync) so the + // browser/wasi-unsupported annotation is scoped as tightly as possible to just the named-pipe path. + [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] + private NamedPipeClient CreateNamedPipeClient() + { + ApplicationStateGuard.Ensure(_commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.DotNetTestPipeOptionKey, out string[]? arguments)); + NamedPipeClient client = new(arguments[0], _environment); + client.RegisterAllSerializers(); + return client; + } + + private DotnetTestWebSocketClient CreateWebSocketClient() + { + ApplicationStateGuard.Ensure(_commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, out string[]? endpointArguments)); + ApplicationStateGuard.Ensure(_commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey, out string[]? tokenArguments)); + DotnetTestWebSocketClient client = new(new Uri(endpointArguments[0], UriKind.Absolute), tokenArguments[0], _environment); + client.RegisterAllSerializers(); + return client; + } + public async Task HelpInvokedAsync() { - RoslynDebug.Assert(_dotnetTestPipeClient is not null); + RoslynDebug.Assert(_transportClient is not null); List commandLineHelpOptions = []; foreach (ICommandLineOptionsProvider commandLineOptionProvider in _commandLineHandler.CommandLineOptionsProviders) @@ -102,7 +139,7 @@ public async Task HelpInvokedAsync() } } - await _dotnetTestPipeClient.RequestReplyAsync(new CommandLineOptionMessages(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath(), [.. commandLineHelpOptions.OrderBy(option => option.Name)]), _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await _transportClient.RequestReplyAsync(new CommandLineOptionMessages(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath(), [.. commandLineHelpOptions.OrderBy(option => option.Name)]), _cancellationTokenSource.CancellationToken).ConfigureAwait(false); } public bool IsIDE { get; private set; } @@ -125,7 +162,7 @@ public async Task HelpInvokedAsync() public async Task IsCompatibleProtocolAsync(string hostType, IReadOnlyDictionary? additionalHandshakeProperties = null) { - RoslynDebug.Assert(_dotnetTestPipeClient is not null); + RoslynDebug.Assert(_transportClient is not null); string supportedProtocolVersions = ProtocolConstants.SupportedVersions; Dictionary properties = new() @@ -140,6 +177,7 @@ public async Task IsCompatibleProtocolAsync(string hostType, IReadOnlyDict { HandshakeMessagePropertyNames.ExecutionId, _environment.GetEnvironmentVariable(EnvironmentVariableConstants.TESTINGPLATFORM_DOTNETTEST_EXECUTIONID) ?? string.Empty }, { HandshakeMessagePropertyNames.InstanceId, InstanceId }, { HandshakeMessagePropertyNames.ExecutionMode, GetExecutionMode() }, + { HandshakeMessagePropertyNames.Transport, _transportKind == DotnetTestTransportKind.WebSocket ? HandshakeMessageTransportNames.WebSocket : HandshakeMessageTransportNames.NamedPipe }, }; if (hostType is HandshakeMessageHostTypes.TestHost or HandshakeMessageHostTypes.ServerTestHost) @@ -157,7 +195,7 @@ public async Task IsCompatibleProtocolAsync(string hostType, IReadOnlyDict HandshakeMessage handshakeMessage = new(properties); - HandshakeMessage response = await _dotnetTestPipeClient.RequestReplyAsync(handshakeMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + HandshakeMessage response = await _transportClient.RequestReplyAsync(handshakeMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); IsIDE = response.Properties?.TryGetValue(HandshakeMessagePropertyNames.IsIDE, out string? isIDEValue) == true && bool.TryParse(isIDEValue, out bool isIDE) && @@ -167,7 +205,13 @@ public async Task IsCompatibleProtocolAsync(string hostType, IReadOnlyDict !RoslynString.IsNullOrEmpty(serverControlPipeName)) { _serverControlPipeName = serverControlPipeName; - IsServerControlChannelSupported = true; + + // The reverse "server control" channel is itself a named pipe advertised by the SDK, regardless of + // which transport carries the primary data channel. On runtimes without named-pipe support + // (browser-wasm, wasi-wasm) we cannot open it, so the feature stays off there - the same + // best-effort fallback already used when the SDK simply never advertises the property at all. A + // WebSocket-based reverse control channel is a natural follow-up but is out of scope here. + IsServerControlChannelSupported = !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); } if (response.Properties?.TryGetValue(HandshakeMessagePropertyNames.SupportedProtocolVersions, out string? protocolVersion) is true) @@ -205,33 +249,33 @@ private string GetAttemptNumber() public async Task SendMessageAsync(IRequest message) { - NamedPipeClient dotnetTestPipeClient = _dotnetTestPipeClient - ?? throw new InvalidOperationException("The dotnet test pipe client is not connected."); + IClient transportClient = _transportClient + ?? throw new InvalidOperationException("The dotnet test transport client is not connected."); switch (message) { case DiscoveredTestMessages discoveredTestMessages: - await dotnetTestPipeClient.RequestReplyAsync(discoveredTestMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(discoveredTestMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; case TestResultMessages testResultMessages: - await dotnetTestPipeClient.RequestReplyAsync(testResultMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(testResultMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; case FileArtifactMessages fileArtifactMessages: - await dotnetTestPipeClient.RequestReplyAsync(fileArtifactMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(fileArtifactMessages, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; case TestSessionEvent testSessionEvent: - await dotnetTestPipeClient.RequestReplyAsync(testSessionEvent, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(testSessionEvent, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; case AzureDevOpsLogMessage azureDevOpsLogMessage: - await dotnetTestPipeClient.RequestReplyAsync(azureDevOpsLogMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(azureDevOpsLogMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; case DisplayMessage displayMessage: - await dotnetTestPipeClient.RequestReplyAsync(displayMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); + await transportClient.RequestReplyAsync(displayMessage, _cancellationTokenSource.CancellationToken).ConfigureAwait(false); break; } } @@ -267,6 +311,10 @@ public Task StartServerControlChannelAsync(Func onCance // exitProcessOnConnectionLoss: false - a dropped control pipe must not kill the test host; the listener // turns it into a cooperative cancel instead. + // NamedPipeClient (and ConnectAndListenForServerControlAsync, which takes one) is unsupported on + // browser/wasi, but IsServerControlChannelSupported is only ever true when neither is the current + // runtime (see IsCompatibleProtocolAsync), so this whole block is unreachable there. +#pragma warning disable CA1416 // IsServerControlChannelSupported already excludes browser/wasi at the call site. var controlClient = new NamedPipeClient(_serverControlPipeName, _environment, exitProcessOnConnectionLoss: false); controlClient.RegisterAllSerializers(); _serverControlPipeClient = controlClient; @@ -275,9 +323,12 @@ public Task StartServerControlChannelAsync(Func onCance // slow/absent control server can never delay (or fail) test execution start. _serverControlListenerTask = Task.Run( () => ConnectAndListenForServerControlAsync(controlClient, onCancelSessionRequestedAsync, _serverControlListenerCts.Token)); +#pragma warning restore CA1416 return Task.CompletedTask; } + [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] private async Task ConnectAndListenForServerControlAsync(NamedPipeClient controlClient, Func onCancelSessionRequestedAsync, CancellationToken cancellationToken) { try @@ -301,6 +352,8 @@ private async Task ConnectAndListenForServerControlAsync(NamedPipeClient control await ListenForServerControlAsync(controlClient, onCancelSessionRequestedAsync, cancellationToken).ConfigureAwait(false); } + [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] private async Task ListenForServerControlAsync(NamedPipeClient controlClient, Func onCancelSessionRequestedAsync, CancellationToken cancellationToken) { try @@ -369,7 +422,9 @@ public async Task OnExitAsync() // Framework cancellation of an already-parked overlapped read is not reliable - disposing the stream is // what forces it to unblock. We cancelled first (above) so the listener treats the resulting failure as // shutdown rather than "host gone => cancel". +#pragma warning disable CA1416 // _serverControlPipeClient is only ever non-null when IsServerControlChannelSupported was true (excludes browser/wasi). _serverControlPipeClient?.Dispose(); +#pragma warning restore CA1416 if (_serverControlListenerTask is { } listenerTask) { @@ -387,7 +442,9 @@ public void Dispose() _serverControlListenerCts?.Cancel(); // Disposing the pipe client forces a parked read to abort even where token cancellation alone would not. +#pragma warning disable CA1416 // _serverControlPipeClient is only ever non-null when IsServerControlChannelSupported was true (excludes browser/wasi). _serverControlPipeClient?.Dispose(); +#pragma warning restore CA1416 if (_serverControlListenerTask is { } listenerTask) { @@ -404,7 +461,7 @@ public void Dispose() } _serverControlListenerCts?.Dispose(); - _dotnetTestPipeClient?.Dispose(); + _transportClient?.Dispose(); } private async Task TryLogAsync(LogLevel logLevel, string message) diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestHelper.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestHelper.cs index ad9aeaa230..6eb667eccd 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestHelper.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestHelper.cs @@ -5,10 +5,57 @@ namespace Microsoft.Testing.Platform; +/// +/// The pre-launch transport selected for the 'dotnet test' pipe protocol (a.k.a. dotnettestcli). The wire +/// protocol itself (message/serializer/version contract) is identical regardless of which value is selected - +/// only the duplex channel that carries it differs. See docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md. +/// +internal enum DotnetTestTransportKind +{ + /// + /// The original -based transport, selected via --dotnet-test-pipe. This + /// is the default whenever only that option is present, preserving exact wire and behavioral compatibility. + /// Not available on browser-wasm or wasi-wasm (no named-pipe support on either runtime). + /// + NamedPipe, + + /// + /// The WebSocket-based transport, selected via --dotnet-test-transport websocket together with + /// --dotnet-test-websocket-endpoint and --dotnet-test-websocket-token. Required on + /// browser-wasm; optional elsewhere. + /// + WebSocket, +} + internal static class DotnetTestHelper { public static bool HasDotnetTestServerOption(this CommandLineHandler commandLineHandler) => commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.ServerOptionKey, out string[]? serverArgs) && serverArgs.Length == 1 && serverArgs[0].Equals(PlatformCommandLineProvider.DotnetTestCliProtocolName, StringComparison.OrdinalIgnoreCase); + + /// + /// Resolves which transport carries the dotnettestcli protocol for this process, mirroring the validation + /// already enforced by (which + /// guarantees, by the time this runs, that exactly one of the two option groups below is present). + /// + public static bool TryGetDotnetTestTransport(this CommandLineHandler commandLineHandler, out DotnetTestTransportKind transport) + { + if (commandLineHandler.TryGetOptionArgumentList(PlatformCommandLineProvider.DotNetTestTransportOptionKey, out string[]? transportArgs) && + transportArgs is { Length: 1 } && + PlatformCommandLineProvider.DotNetTestTransportWebSocketArgument.Equals(transportArgs[0], StringComparison.OrdinalIgnoreCase)) + { + transport = DotnetTestTransportKind.WebSocket; + return true; + } + + if (commandLineHandler.IsOptionSet(PlatformCommandLineProvider.DotNetTestPipeOptionKey)) + { + transport = DotnetTestTransportKind.NamedPipe; + return true; + } + + transport = default; + return false; + } } diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Constants.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Constants.cs index 8e11c4ba1b..b296e102d3 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Constants.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Constants.cs @@ -95,6 +95,25 @@ internal static class HandshakeMessagePropertyNames // Semicolon-separated lowercase file extensions used as a compatibility fallback for untagged artifacts. internal const byte SupportedPostProcessorExtensionsLegacy = 15; + + // Identifies which pre-launch transport carried this handshake: a value from HandshakeMessageTransportNames + // ("NamedPipe" or "WebSocket"). The wire protocol is identical over either transport; this property exists + // purely for diagnostics/telemetry and future negotiation (e.g. so the SDK can log or validate which + // transport a given connecting process actually used). Always sent by the test host / test host controller + // / orchestrator; an older SDK that does not recognize the id simply ignores it, so it is not gated on the + // negotiated protocol version, but ProtocolConstants.SupportedVersions was still bumped to 1.5.0 alongside it + // so the negotiated-version state advances in lockstep with the other additive capabilities in this file. + internal const byte Transport = 16; +} + +[Embedded] +internal static class HandshakeMessageTransportNames +{ + // System.IO.Pipes-based transport (the original, default transport selected via --dotnet-test-pipe). + internal const string NamedPipe = "NamedPipe"; + + // WebSocket-based transport (selected via --dotnet-test-transport websocket), required on browser-wasm. + internal const string WebSocket = "WebSocket"; } [Embedded] @@ -184,5 +203,12 @@ internal static class ProtocolConstants // --timeout, ...). The feature is gated on the presence of the handshake property (a capability), not on this // version string, so an older SDK that never advertises the pipe leaves the feature disabled. The version is // still bumped so the negotiated-version state advances in lockstep. - internal const string SupportedVersions = "1.0.0;1.1.0;1.2.0;1.3.0;1.4.0"; + // 1.5.0 adds the Transport handshake property (HandshakeMessagePropertyNames.Transport): the test host now + // always reports which pre-launch transport it connected over ("NamedPipe" or "WebSocket" - see + // HandshakeMessageTransportNames). This is a capability-style property gated on presence, not on this version + // string, so an older SDK that does not look at it is unaffected; the version is bumped only so the + // negotiated-version state advances in lockstep with the other additive capabilities in this file. Introduced + // alongside the WebSocket transport (docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md), which is + // required to bootstrap the dotnettestcli protocol on runtimes without System.IO.Pipes support (browser-wasm). + internal const string SupportedVersions = "1.0.0;1.1.0;1.2.0;1.3.0;1.4.0;1.5.0"; } diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs index a362ed4eda..09a3b89fc5 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs @@ -10,7 +10,6 @@ namespace Microsoft.Testing.Platform.IPC; -[UnsupportedOSPlatform("browser")] internal sealed class DotnetTestDataConsumer : IPushOnlyProtocolConsumer { private readonly DotnetTestConnection? _dotnetTestConnection; diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs new file mode 100644 index 0000000000..55f40bf78c --- /dev/null +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.JavaScript; + +namespace Microsoft.Testing.Platform.IPC; + +/// +/// Adapts a browser-native WebSocket object (reached through JS interop, following the same +/// [JSImport]/[JSExport] pattern as ) to a duplex +/// , so the transport-neutral framing in can drive it +/// unchanged - the same way adapts +/// on non-browser runtimes. is not implemented on +/// browser-wasm (it throws ), so this type talks to the +/// browser's own WebSocket API directly instead. +/// +/// +/// +/// The companion JS module is embedded as a string constant and imported through a data: URL via +/// . This keeps the browser +/// transport fully self-contained in this file - no changes to the generated wasm bootstrap/entry point or to +/// the published asset set are required, unlike a conventional .js asset shipped alongside the app. +/// +/// +/// Each connection owns one JS WebSocket object (kept alive on the .NET side as a +/// proxy). send writes one binary frame per call, mirroring the one-frame-per-WriteAsync contract +/// the framing layer already relies on for named pipes and the non-browser WebSocket adapter. Frames are +/// exchanged as base64 strings (see the module source for why) rather than raw bytes. receive returns +/// the next queued message, or an empty string once the socket has closed (a real protocol frame is always at +/// least 8 bytes, so this is an unambiguous close sentinel) - messages arriving before the .NET side calls +/// receive are buffered in a JS-side queue so no data is lost while a request/reply round-trip is in +/// flight. +/// +/// +[SupportedOSPlatform("browser")] +internal sealed partial class BrowserWebSocketDuplexStream : Stream +{ + private const string ModuleName = "Microsoft.Testing.Platform/DotnetTestWebSocket"; + + // language=javascript + private const string ModuleSource = """ + export function open(url) { + return new Promise((resolve, reject) => { + let ws; + try { + ws = new WebSocket(url); + } catch (e) { + reject(e); + return; + } + + ws.binaryType = "arraybuffer"; + ws._queue = []; + ws._waiter = null; + ws._closed = false; + ws._openRejected = false; + + ws.onopen = () => resolve(ws); + ws.onerror = () => { + if (!ws._openRejected) { + ws._openRejected = true; + reject(new Error("The WebSocket connection failed or was refused by the peer.")); + } + }; + ws.onmessage = (ev) => { + const data = new Uint8Array(ev.data); + if (ws._waiter) { + const waiter = ws._waiter; + ws._waiter = null; + waiter.resolve(toBase64(data)); + } else { + ws._queue.push(data); + } + }; + ws.onclose = () => { + ws._closed = true; + if (ws._waiter) { + const waiter = ws._waiter; + ws._waiter = null; + waiter.resolve(""); + } + }; + }); + } + + // Data is exchanged as base64 strings rather than raw byte arrays: the wasm JS-interop source + // generator does not support marshalling byte[]/Uint8Array across an async (Task-returning) boundary, + // but string marshalling is always supported. A real protocol frame is always at least 8 bytes (4-byte + // length header + 4-byte serializer id), so an empty string is an unambiguous "socket closed" sentinel. + function toBase64(bytes) { + // Avoid spreading very large arrays into String.fromCharCode (call-stack argument limits); + // build the binary string in bounded chunks instead. + let binary = ""; + const chunkSize = 0x8000; + for (let i = 0; i < bytes.length; i += chunkSize) { + binary += String.fromCharCode.apply(null, bytes.subarray(i, i + chunkSize)); + } + + return btoa(binary); + } + + function fromBase64(base64) { + const binary = atob(base64); + const bytes = new Uint8Array(binary.length); + for (let i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i); + } + + return bytes; + } + + export function send(ws, base64Data) { + ws.send(fromBase64(base64Data)); + } + + export function receive(ws) { + if (ws._queue.length > 0) { + return Promise.resolve(toBase64(ws._queue.shift())); + } + + if (ws._closed) { + return Promise.resolve(""); + } + + return new Promise((resolve, reject) => { + ws._waiter = { resolve, reject }; + }); + } + + export function close(ws) { + try { + ws.close(); + } catch { + // Best-effort: the socket may already be closed/closing. + } + } + """; + + private static Task? s_moduleReady; + + private readonly JSObject _socket; + private byte[] _pendingRead = []; + private int _pendingReadOffset; + private bool _disposed; + + private BrowserWebSocketDuplexStream(JSObject socket) => _socket = socket; + + /// + /// Imports the companion JS module (idempotent - safe to call before every connection attempt) and opens a + /// new browser WebSocket to . The returned stream is only valid once the JS onopen + /// event has fired; a connection failure (refused, DNS, TLS, ...) surfaces as an awaited exception here rather + /// than being discovered on the first read/write. + /// + public static async Task ConnectAsync(Uri uri, CancellationToken cancellationToken) + { + s_moduleReady ??= JSHost.ImportAsync(ModuleName, $"data:text/javascript;charset=utf-8;base64,{Convert.ToBase64String(Encoding.UTF8.GetBytes(ModuleSource))}", cancellationToken); + await s_moduleReady.ConfigureAwait(false); + + JSObject socket = await OpenAsync(uri.ToString()).ConfigureAwait(false); + return new BrowserWebSocketDuplexStream(socket); + } + + public override bool CanRead => true; + + public override bool CanWrite => true; + + public override bool CanSeek => false; + + public override long Length => throw new NotSupportedException(); + + public override long Position + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + public override void Flush() + { + } + + public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask; + + public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); + + public override void SetLength(long value) => throw new NotSupportedException(); + + public override int Read(byte[] buffer, int offset, int count) + => throw new NotSupportedException($"{nameof(BrowserWebSocketDuplexStream)} only supports asynchronous reads."); + + public override void Write(byte[] buffer, int offset, int count) + => throw new NotSupportedException($"{nameof(BrowserWebSocketDuplexStream)} only supports asynchronous writes."); + + public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + if (_pendingReadOffset >= _pendingRead.Length) + { + string next = await ReceiveAsync(_socket).ConfigureAwait(false); + + // A real protocol frame is always at least 8 bytes (4-byte length header + 4-byte serializer id), so + // an empty result unambiguously means the JS module resolved the close sentinel (see the 'receive' + // function above) - the peer went away. Surface EOF exactly like a clean named-pipe disconnect so + // the shared connection-loss handling in DotnetTestWebSocketClient applies uniformly. + if (next.Length == 0) + { + return 0; + } + + _pendingRead = Convert.FromBase64String(next); + _pendingReadOffset = 0; + } + + int toCopy = Math.Min(count, _pendingRead.Length - _pendingReadOffset); + Array.Copy(_pendingRead, _pendingReadOffset, buffer, offset, toCopy); + _pendingReadOffset += toCopy; + return toCopy; + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + Send(_socket, Convert.ToBase64String(buffer, offset, count)); + return Task.CompletedTask; + } + + protected override void Dispose(bool disposing) + { + if (!_disposed && disposing) + { + try + { + Close(_socket); + } + catch (JSException) + { + // Best-effort close; the socket may already be gone (peer closed first, page navigating away, ...). + } + + _disposed = true; + } + + base.Dispose(disposing); + } + + [JSImport("open", ModuleName)] + private static partial Task OpenAsync(string url); + + [JSImport("send", ModuleName)] + private static partial void Send(JSObject socket, string base64Data); + + [JSImport("receive", ModuleName)] + private static partial Task ReceiveAsync(JSObject socket); + + [JSImport("close", ModuleName)] + private static partial void Close(JSObject socket); +} + +#endif diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs new file mode 100644 index 0000000000..8f9250b098 --- /dev/null +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Net.WebSockets; + +namespace Microsoft.Testing.Platform.IPC; + +/// +/// Adapts a connected (typically a client-side +/// , but any concrete works - e.g. a +/// server-side socket obtained from an HTTP listener, which is how tests exercise this adapter without a real +/// peer) to a duplex so the transport-neutral framing in +/// (originally written against ) can drive it unchanged. Each +/// WriteAsync call from the framing layer writes exactly one already-assembled frame, so it maps 1:1 to +/// one binary WebSocket message (endOfMessage: true). Reads are treated as a plain byte stream: +/// consecutive chunks are handed back +/// verbatim (buffering any leftover bytes across calls) without relying on message boundaries, which keeps this +/// adapter correct regardless of how the peer chooses to fragment its writes. +/// +/// +/// This adapter is for non-browser runtimes only: throws +/// on browser-wasm. See BrowserWebSocketDuplexStream +/// for the browser-specific JS-interop implementation. +/// +[UnsupportedOSPlatform("browser")] +internal sealed class ClientWebSocketDuplexStream : Stream +{ + private readonly WebSocket _webSocket; + private readonly byte[] _receiveBuffer = new byte[8192]; + private int _receiveOffset; + private int _receiveCount; + private bool _disposed; + + public ClientWebSocketDuplexStream(WebSocket webSocket) => _webSocket = webSocket; + + public override bool CanRead => true; + + public override bool CanWrite => true; + + public override bool CanSeek => false; + + public override long Length => throw new NotSupportedException(); + + public override long Position + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + public override void Flush() + { + // WebSocket sends are not buffered on our side; nothing to flush. + } + + public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask; + + public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); + + public override void SetLength(long value) => throw new NotSupportedException(); + + public override int Read(byte[] buffer, int offset, int count) + => throw new NotSupportedException($"{nameof(ClientWebSocketDuplexStream)} only supports asynchronous reads."); + + public override void Write(byte[] buffer, int offset, int count) + => throw new NotSupportedException($"{nameof(ClientWebSocketDuplexStream)} only supports asynchronous writes."); + + public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + if (_receiveCount == 0) + { + WebSocketReceiveResult result = await _webSocket.ReceiveAsync(new ArraySegment(_receiveBuffer), cancellationToken).ConfigureAwait(false); + if (result.MessageType == WebSocketMessageType.Close) + { + return 0; + } + + _receiveOffset = 0; + _receiveCount = result.Count; + + // A binary frame can legitimately carry zero bytes (e.g. an empty keep-alive); loop rather than + // reporting a false EOF. The framing layer above always reads a bounded number of bytes so this + // cannot spin indefinitely against a well-behaved peer. + if (_receiveCount == 0 && !result.EndOfMessage) + { + return await ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); + } + } + + int toCopy = Math.Min(count, _receiveCount); + Array.Copy(_receiveBuffer, _receiveOffset, buffer, offset, toCopy); + _receiveOffset += toCopy; + _receiveCount -= toCopy; + return toCopy; + } + + public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + => await _webSocket.SendAsync(new ArraySegment(buffer, offset, count), WebSocketMessageType.Binary, endOfMessage: true, cancellationToken).ConfigureAwait(false); + + protected override void Dispose(bool disposing) + { + if (!_disposed && disposing) + { + _webSocket.Dispose(); + _disposed = true; + } + + base.Dispose(disposing); + } +} diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs new file mode 100644 index 0000000000..c04699781c --- /dev/null +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Net.WebSockets; + +using Microsoft.Testing.Platform.Helpers; + +namespace Microsoft.Testing.Platform.IPC; + +/// +/// A implementation of the 'dotnet test' pipe protocol (a.k.a. dotnettestcli) over a +/// WebSocket transport instead of a named pipe. This is the transport used on runtimes that cannot open +/// connections - today, browser-wasm (via BrowserWebSocketDuplexStream); +/// it is also available on every other runtime (via , wrapping +/// ) for testing and for scenarios where a loopback WebSocket gateway is preferable +/// to a named pipe (e.g. crossing a container/sandbox boundary). +/// +/// +/// The wire protocol (message/serializer/version contract, framing) is entirely unchanged from the named-pipe +/// transport: this class reuses and +/// against whichever duplex +/// produces. Only the connection bootstrap (how the duplex channel is established +/// and authenticated) differs from . +/// +internal sealed class DotnetTestWebSocketClient : NamedPipeConnectionBase, IClient +{ + private readonly Uri _endpoint; + private readonly string _authToken; + private readonly IEnvironment _environment; + private readonly bool _exitProcessOnConnectionLoss; + private readonly SemaphoreSlim _lock = new(1, 1); + + private Stream? _stream; + private ClientWebSocket? _clientWebSocket; + private bool _disposed; + + /// + /// Initializes a new instance of the class for the primary data + /// channel (exits the process on connection loss). + /// + /// + /// The loopback WebSocket endpoint (e.g. ws://127.0.0.1:12345/dotnettest) that the SDK/gateway is + /// already listening on. Resolved and supplied by the SDK, mirroring how the named-pipe transport receives an + /// already-resolved OS pipe name rather than computing one itself. + /// + /// + /// A per-run secret the SDK generated for this connection. It is never logged; see + /// for how it is transmitted. + /// + /// The environment abstraction used for process-exit on connection loss. + public DotnetTestWebSocketClient(Uri endpoint, string authToken, IEnvironment environment) + : this(endpoint, authToken, environment, exitProcessOnConnectionLoss: true) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The loopback WebSocket endpoint (e.g. ws://127.0.0.1:12345/dotnettest) that the SDK/gateway is + /// already listening on. Resolved and supplied by the SDK, mirroring how the named-pipe transport receives an + /// already-resolved OS pipe name rather than computing one itself. + /// + /// + /// A per-run secret the SDK generated for this connection. It is never logged; see + /// for how it is transmitted. + /// + /// The environment abstraction used for process-exit on connection loss. + /// + /// See for the semantics; the primary data channel + /// uses , auxiliary channels use . + /// + public DotnetTestWebSocketClient(Uri endpoint, string authToken, IEnvironment environment, bool exitProcessOnConnectionLoss) + { + _endpoint = endpoint; + _authToken = authToken; + _environment = environment; + _exitProcessOnConnectionLoss = exitProcessOnConnectionLoss; + } + + public bool IsConnected => _stream is not null; + + public async Task ConnectAsync(CancellationToken cancellationToken) + { + Uri authenticatedEndpoint = BuildAuthenticatedUri(_endpoint, _authToken); + +#if NET7_0_OR_GREATER + if (OperatingSystem.IsBrowser()) + { + _stream = await BrowserWebSocketDuplexStream.ConnectAsync(authenticatedEndpoint, cancellationToken).ConfigureAwait(false); + return; + } +#endif + var clientWebSocket = new ClientWebSocket(); + try + { + await clientWebSocket.ConnectAsync(authenticatedEndpoint, cancellationToken).ConfigureAwait(false); + } + catch + { + clientWebSocket.Dispose(); + throw; + } + + _clientWebSocket = clientWebSocket; + _stream = new ClientWebSocketDuplexStream(clientWebSocket); + } + + /// + /// Appends the per-run authentication token to as a query-string parameter. + /// + /// + /// The browser's native WebSocket constructor only accepts a URL and an optional subprotocol list - it + /// cannot set arbitrary request headers on the upgrade handshake - so a bearer header is not an option for the + /// browser transport. A query-string token is the same approach ASP.NET Core SignalR uses for its WebSocket + /// transport for the identical reason. This is also why CORS cannot serve as authentication here: CORS governs + /// which origins may *read* a cross-origin response, not who may *open* a WebSocket connection in the first + /// place, so without an explicit token any process that can reach the loopback port could connect. Callers must + /// never log the returned verbatim (or any log line derived from it) since it carries the + /// secret - diagnostics should log only //. + /// + internal static Uri BuildAuthenticatedUri(Uri endpoint, string token) + { + string tokenFragment = $"dotnetTestToken={Uri.EscapeDataString(token)}"; + string original = endpoint.OriginalString; + int fragmentIndex = original.IndexOf('#'); + string beforeFragment = fragmentIndex >= 0 ? original[..fragmentIndex] : original; + string fragment = fragmentIndex >= 0 ? original[fragmentIndex..] : string.Empty; + string separator = beforeFragment.Contains('?') ? "&" : "?"; + return new Uri($"{beforeFragment}{separator}{tokenFragment}{fragment}", UriKind.Absolute); + } + + public async Task RequestReplyAsync(TRequest request, CancellationToken cancellationToken) + where TRequest : IRequest + where TResponse : IResponse + { + RoslynDebug.Assert(_stream is not null); + + await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); + try + { + INamedPipeSerializer requestSerializer = GetSerializer(typeof(TRequest)); + + try + { + await WriteMessageAsync(_stream, requestSerializer, request!, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) when (ex is IOException or ObjectDisposedException or WebSocketException) + { + // The peer disconnected while we were writing the request. Mirror NamedPipeClient's handling: if + // we cannot deliver the request there's no way to recover, so exit abnormally instead of + // surfacing a raw transport error to the caller (for the primary data channel). + if (!_exitProcessOnConnectionLoss) + { + throw; + } + + _environment.Exit((int)ExitCode.GenericFailure); + throw; + } + + object? response = await ReadNextMessageAsync(_stream, cancellationToken).ConfigureAwait(false); + if (response is null) + { + if (!_exitProcessOnConnectionLoss) + { + throw new IOException("The WebSocket transport was closed by the peer before a response was received."); + } + + try + { + await Console.Error.WriteLineAsync($"[DotnetTestWebSocketClient] The WebSocket transport was closed by the peer before a response was received. The peer process likely exited or was killed. Terminating with exit code {(int)ExitCode.GenericFailure}.").ConfigureAwait(false); + } + catch (Exception ex) when (ex is IOException or ObjectDisposedException or InvalidOperationException or NotSupportedException or ArgumentException or OperationCanceledException) + { + // Best-effort diagnostic only; never let logging failures shadow the original problem. + } + + _environment.Exit((int)ExitCode.GenericFailure); + throw new InvalidOperationException("The WebSocket transport was closed by the peer before a response was received."); + } + + return (TResponse)response!; + } + finally + { + _lock.Release(); + } + } + + public void Dispose() + { + if (_disposed) + { + return; + } + + _disposed = true; + _lock.Dispose(); + DisposeBuffers(); + _stream?.Dispose(); + _clientWebSocket?.Dispose(); + } +} diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeBaselineTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeBaselineTests.cs index ca3f8b2bb3..178c9fd87e 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeBaselineTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeBaselineTests.cs @@ -25,12 +25,13 @@ public class DotnetTestPipeBaselineTests : AcceptanceTestBase x.Name == PlatformCommandLineProvider.DotNetTestTransportOptionKey); + + ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [argument]).ConfigureAwait(false); + Assert.IsTrue(validateOptionsResult.IsValid); + } + + [TestMethod] + [DataRow("named-pipe")] + [DataRow("http")] + [DataRow("")] + public async Task IsInvalid_When_DotnetTestTransport_HasUnknownArgument(string argument) + { + var provider = new PlatformCommandLineProvider(); + CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == PlatformCommandLineProvider.DotNetTestTransportOptionKey); + + ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [argument]).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual( + string.Format( + CultureInfo.InvariantCulture, + PlatformResources.PlatformCommandLineDotnetTestTransportInvalidArgument, + argument, + "'pipe', 'websocket'"), + validateOptionsResult.ErrorMessage); + } + + [TestMethod] + public async Task IsValid_When_Server_DotnetTestCli_With_WebSocketTransport_And_EndpointAndToken() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestTransportOptionKey, ["websocket"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, ["ws://127.0.0.1:5000/dotnettest"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey, ["some-token"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsTrue(validateOptionsResult.IsValid); + } + + [TestMethod] + public async Task IsInvalid_When_Server_DotnetTestCli_With_WebSocketTransport_Missing_Endpoint() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestTransportOptionKey, ["websocket"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey, ["some-token"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual(PlatformResources.PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken, validateOptionsResult.ErrorMessage); + } + + [TestMethod] + public async Task IsInvalid_When_Server_DotnetTestCli_With_WebSocketTransport_Missing_Token() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestTransportOptionKey, ["websocket"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, ["ws://127.0.0.1:5000/dotnettest"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual(PlatformResources.PlatformCommandLineDotnetTestWebSocketRequiresEndpointAndToken, validateOptionsResult.ErrorMessage); + } + + [TestMethod] + public async Task IsInvalid_When_Server_DotnetTestCli_With_Pipe_And_WebSocketTransport_Together() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestPipeOptionKey, ["pipe-name"] }, + { PlatformCommandLineProvider.DotNetTestTransportOptionKey, ["websocket"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, ["ws://127.0.0.1:5000/dotnettest"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey, ["some-token"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual(PlatformResources.PlatformCommandLineDotnetTestTransportConflict, validateOptionsResult.ErrorMessage); + } + + [TestMethod] + public async Task IsInvalid_When_Server_DotnetTestCli_With_Pipe_And_WebSocketEndpoint_Together() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestPipeOptionKey, ["pipe-name"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, ["ws://127.0.0.1:5000/dotnettest"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual(PlatformResources.PlatformCommandLineDotnetTestTransportConflict, validateOptionsResult.ErrorMessage); + } + + [TestMethod] + public async Task IsInvalid_When_Server_DotnetTestCli_With_WebSocketOptions_But_Transport_Pipe() + { + var provider = new PlatformCommandLineProvider(); + var options = new Dictionary + { + { PlatformCommandLineProvider.ServerOptionKey, ["dotnettestcli"] }, + { PlatformCommandLineProvider.DotNetTestTransportOptionKey, ["pipe"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketEndpointOptionKey, ["ws://127.0.0.1:5000/dotnettest"] }, + { PlatformCommandLineProvider.DotNetTestWebSocketTokenOptionKey, ["some-token"] }, + }; + + ValidationResult validateOptionsResult = await provider.ValidateCommandLineOptionsAsync(new TestCommandLineOptions(options)).ConfigureAwait(false); + Assert.IsFalse(validateOptionsResult.IsValid); + Assert.AreEqual(PlatformResources.PlatformCommandLineDotnetTestWebSocketOptionsRequireTransport, validateOptionsResult.ErrorMessage); + } + [TestMethod] public void IsListTestsJsonOutput_ReturnsTrueOnlyWhenJsonArgumentSet() { diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs new file mode 100644 index 0000000000..93e9b73610 --- /dev/null +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if NET +using System.Net; +using System.Net.Sockets; +using System.Net.WebSockets; +using System.Security.Cryptography; +using System.Text; +#endif + +using Microsoft.Testing.Platform.Helpers; +using Microsoft.Testing.Platform.IPC; +using Microsoft.Testing.Platform.IPC.Models; +using Microsoft.Testing.Platform.IPC.Serializers; + +using Moq; + +namespace Microsoft.Testing.Platform.UnitTests; + +/// +/// Tests for the WebSocket transport of the 'dotnet test' pipe protocol (, +/// ). These tests focus on the transport bootstrap itself - +/// authentication, connect, and request/reply framing over a real loopback WebSocket - since the wire protocol +/// carried over the connection is exactly the one the named-pipe transport already uses (see +/// /). +/// +[TestClass] +[UnsupportedOSPlatform("browser")] +public sealed class DotnetTestWebSocketClientTests +{ + [TestMethod] + public void BuildAuthenticatedUri_AppendsTokenAsQueryParameter_WhenNoExistingQuery() + { + Uri result = DotnetTestWebSocketClient.BuildAuthenticatedUri(new Uri("ws://127.0.0.1:5000/dotnettest"), "abc123"); + + Assert.AreEqual("ws://127.0.0.1:5000/dotnettest?dotnetTestToken=abc123", result.AbsoluteUri); + } + + [TestMethod] + public void BuildAuthenticatedUri_AppendsTokenWithAmpersand_WhenQueryAlreadyPresent() + { + Uri result = DotnetTestWebSocketClient.BuildAuthenticatedUri(new Uri("ws://127.0.0.1:5000/dotnettest?foo=bar"), "abc123"); + + Assert.AreEqual("ws://127.0.0.1:5000/dotnettest?foo=bar&dotnetTestToken=abc123", result.AbsoluteUri); + } + + [TestMethod] + public void BuildAuthenticatedUri_EscapesSpecialCharactersInToken() + { + Uri result = DotnetTestWebSocketClient.BuildAuthenticatedUri(new Uri("ws://127.0.0.1:5000/dotnettest"), "a b&c=d"); + + Assert.AreEqual("ws://127.0.0.1:5000/dotnettest?dotnetTestToken=a%20b%26c%3Dd", result.AbsoluteUri); + } + + [TestMethod] + public void BuildAuthenticatedUri_InsertsTokenBeforeFragment() + { + Uri result = DotnetTestWebSocketClient.BuildAuthenticatedUri(new Uri("ws://127.0.0.1:5000/dotnettest#frag"), "abc123"); + + Assert.AreEqual("ws://127.0.0.1:5000/dotnettest?dotnetTestToken=abc123#frag", result.AbsoluteUri); + } + +#if NET + // Exercises the full stack end-to-end over a real loopback socket: DotnetTestWebSocketClient.ConnectAsync + // (with the auth token propagated as a query parameter) and ClientWebSocketDuplexStream framing, using the + // real HandshakeMessage/HandshakeMessageSerializer wire types. The "server" side is a minimal hand-rolled + // RFC 6455 opening handshake (HttpListener's WebSocket support is Windows-only, so it cannot be used here) + // followed by System.Net.WebSockets.WebSocket.CreateFromStream, then reads/writes frames manually using the + // documented wire format (int32 payload length + int32 serializer id + body) so this test does not depend on + // NamedPipeConnectionBase (whose framing is already covered directly by the named-pipe transport tests). + [TestMethod] + [Timeout(30_000, CooperativeCancellation = true)] + public async Task ConnectAsync_RequestReplyAsync_RoundTripsRealFramingOverLoopbackWebSocket() + { + using CancellationTokenSource cts = new(TimeSpan.FromSeconds(25)); + TcpListener listener = new(IPAddress.Loopback, 0); + listener.Start(); + try + { + int port = ((IPEndPoint)listener.LocalEndpoint).Port; + + Task<(HandshakeMessage Received, string RequestLine)> serverTask = AcceptAndHandleOneRequestAsync(listener, cts.Token); + + IEnvironment environment = new Mock().Object; + DotnetTestWebSocketClient client = new(new Uri($"ws://127.0.0.1:{port}/dotnettest"), "s3cr3t-token", environment, exitProcessOnConnectionLoss: false); + RegisterSerializerViaReflection(client, new HandshakeMessageSerializer(), typeof(HandshakeMessage)); + + try + { + await client.ConnectAsync(cts.Token); + Assert.IsTrue(client.IsConnected); + + HandshakeMessage sent = new(new Dictionary { [0] = "1234", [5] = "TestHost" }); + HandshakeMessage response = await client.RequestReplyAsync(sent, cts.Token); + Assert.IsNotNull(response.Properties); + Assert.AreEqual("negotiated-value", response.Properties![9]); + + (HandshakeMessage received, string requestLine) = await serverTask; + Assert.AreEqual("1234", received.Properties?[0]); + Assert.AreEqual("TestHost", received.Properties?[5]); + + // The token must have travelled as a query-string parameter (browsers cannot set custom + // headers on the WebSocket upgrade handshake) - see DotnetTestWebSocketClient.BuildAuthenticatedUri. + Assert.Contains("dotnetTestToken=s3cr3t-token", requestLine); + } + finally + { + client.Dispose(); + } + } + finally + { + listener.Stop(); + } + } + + private static async Task<(HandshakeMessage Received, string RequestLine)> AcceptAndHandleOneRequestAsync(TcpListener listener, CancellationToken cancellationToken) + { + using TcpClient tcpClient = await listener.AcceptTcpClientAsync(cancellationToken); + NetworkStream networkStream = tcpClient.GetStream(); + + string requestText = await CompleteServerHandshakeAsync(networkStream, cancellationToken); + + using var serverSocket = WebSocket.CreateFromStream(networkStream, isServer: true, subProtocol: null, keepAliveInterval: Timeout.InfiniteTimeSpan); + ClientWebSocketDuplexStream stream = new(serverSocket); + + byte[] requestPayload = await ReadFrameAsync(stream, cancellationToken); + int serializerId = BitConverter.ToInt32(requestPayload, 0); + Assert.AreEqual(HandshakeMessageFieldsId.MessagesSerializerId, serializerId); + + using MemoryStream requestBody = new(requestPayload, 4, requestPayload.Length - 4); + HandshakeMessageSerializer serializer = new(); + var received = (HandshakeMessage)ProtocolSerializerTestHelper.Deserialize(serializer, requestBody); + + HandshakeMessage reply = new(new Dictionary { [9] = "negotiated-value" }); + using MemoryStream replyBody = new(); + ProtocolSerializerTestHelper.Serialize(serializer, reply, replyBody); + await WriteFrameAsync(stream, HandshakeMessageFieldsId.MessagesSerializerId, replyBody.ToArray(), cancellationToken); + + return (received, requestText); + } + + // Minimal RFC 6455 server-side opening handshake: read the HTTP request line + headers (up to the blank + // line terminator), extract Sec-WebSocket-Key, and reply with the computed Sec-WebSocket-Accept. Everything + // after this point is real WebSocket framing, handled by WebSocket.CreateFromStream. + private static async Task CompleteServerHandshakeAsync(NetworkStream networkStream, CancellationToken cancellationToken) + { + List buffer = []; + byte[] singleByte = new byte[1]; + while (true) + { + int read = await networkStream.ReadAsync(singleByte, cancellationToken); + if (read == 0) + { + throw new IOException("Connection closed before the WebSocket handshake completed."); + } + + buffer.Add(singleByte[0]); + if (buffer.Count >= 4 && + buffer[^4] == (byte)'\r' && buffer[^3] == (byte)'\n' && + buffer[^2] == (byte)'\r' && buffer[^1] == (byte)'\n') + { + break; + } + } + + string requestText = Encoding.ASCII.GetString([.. buffer]); + string key = requestText + .Split("\r\n") + .Single(line => line.StartsWith("Sec-WebSocket-Key:", StringComparison.OrdinalIgnoreCase)) + .Split(':', 2)[1] + .Trim(); + + string accept = Convert.ToBase64String(SHA1.HashData(Encoding.ASCII.GetBytes(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))); + string response = $"HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: {accept}\r\n\r\n"; + await networkStream.WriteAsync(Encoding.ASCII.GetBytes(response), cancellationToken); + return requestText; + } + + // Mirrors the documented wire format (§4 of docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md): + // int32 payloadLength (= 4 + body.Length), int32 serializerId, then the body. Deliberately independent of + // NamedPipeConnectionBase so this test does not depend on which of its (possibly duplicated, see this + // project's local IPC/*.cs source links) copies is in scope. + private static async Task ReadFrameAsync(Stream stream, CancellationToken cancellationToken) + { + byte[] header = new byte[4]; + await ReadExactAsync(stream, header, cancellationToken); + int payloadLength = BitConverter.ToInt32(header, 0); + byte[] payload = new byte[payloadLength]; + await ReadExactAsync(stream, payload, cancellationToken); + return payload; + } + + private static async Task ReadExactAsync(Stream stream, byte[] buffer, CancellationToken cancellationToken) + { + int offset = 0; + while (offset < buffer.Length) + { + int read = await stream.ReadAsync(buffer.AsMemory(offset), cancellationToken); + if (read == 0) + { + throw new IOException("Unexpected end of stream while reading a frame."); + } + + offset += read; + } + } + + private static async Task WriteFrameAsync(Stream stream, int serializerId, byte[] body, CancellationToken cancellationToken) + { + int payloadLength = 4 + body.Length; + byte[] frame = new byte[4 + payloadLength]; + BitConverter.GetBytes(payloadLength).CopyTo(frame, 0); + BitConverter.GetBytes(serializerId).CopyTo(frame, 4); + body.CopyTo(frame, 8); + await stream.WriteAsync(frame, cancellationToken); + } + + // NamedPipeBase.RegisterSerializer is public but inherited from a base class that is also (separately) + // compiled directly into this test project from linked source (see this project's IPC/*.cs Compile Include + // items). That makes ordinary strongly-typed member lookup on the assembly-referenced DotnetTestWebSocketClient + // ambiguous with the test project's own same-named local copy, so - exactly like ProtocolSerializerTestHelper + // does for the serializer Serialize/Deserialize methods - this reaches the real inherited method via + // reflection instead, which resolves purely at runtime against the actual (unambiguous) object instance. + private static void RegisterSerializerViaReflection(object client, object serializer, Type messageType) + { + MethodInfo method = client.GetType().GetMethod("RegisterSerializer", BindingFlags.Public | BindingFlags.Instance) + ?? throw new InvalidOperationException("RegisterSerializer method not found via reflection."); + method.Invoke(client, [serializer, messageType]); + } +#endif +} diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/ProtocolTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/ProtocolTests.cs index d46793e4b8..0a7f7b3296 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/ProtocolTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/ProtocolTests.cs @@ -534,6 +534,6 @@ public void ProtocolVersion_IsStable() // Indirect through a collection so the MSTest analyzer does not flag the comparison of a compile-time // constant as "always true" (MSTEST0032). string[] versions = [ProtocolConstants.SupportedVersions]; - Assert.AreEqual("1.0.0;1.1.0;1.2.0;1.3.0;1.4.0", versions[0]); + Assert.AreEqual("1.0.0;1.1.0;1.2.0;1.3.0;1.4.0;1.5.0", versions[0]); } } From f49d7e650d461cc5860a2bbe48ca8a4217f89bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 21 Jul 2026 17:27:58 +0200 Subject: [PATCH 02/20] Address code review findings in WebSocket transport - BrowserWebSocketDuplexStream: honor cancellationToken during reads via a new WaitForReceiveAsync helper that races the JS receive() promise against the token, so a cancelled request/timeout no longer hangs forever on browser-wasm. - ClientWebSocketDuplexStream: fix a zero-length-message EOF bug (a legitimate empty, non-Close WebSocket message was misreported as end-of-stream), and convert the retry from recursion to a loop to avoid a potential StackOverflowException against a peer sending many consecutive empty messages. - DotnetTestWebSocketClient.RequestReplyAsync: catch transport exceptions from ReadNextMessageAsync (previously only the write path was guarded), since an abrupt WebSocket disconnect surfaces as a thrown exception rather than a clean 0-byte EOF the way a named pipe does. Factored the shared connection-loss handling (exit-process vs. throw) into HandleMissingResponseAsync. - Added tests: large-message round-trip spanning multiple WebSocket receives, server-closes-without-responding (verifies IOException + no process exit when exitProcessOnConnectionLoss is false), and cancellation of a pending RequestReplyAsync (verifies OperationCanceledException instead of a hang). Found via 3 rounds of code review (2 code-review passes + 1 rubber-duck pass); all reported findings fixed and re-verified. Full solution build and the Microsoft.Testing.Platform.UnitTests / DotnetTestProtocolContract.UnitTests suites pass (1459 + 24 tests). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 282499c0-c68f-41eb-890a-ad47bb78ce54 --- .../Transport/BrowserWebSocketDuplexStream.cs | 37 +++- .../Transport/ClientWebSocketDuplexStream.cs | 21 +- .../Transport/DotnetTestWebSocketClient.cs | 70 ++++-- .../IPC/DotnetTestWebSocketClientTests.cs | 200 ++++++++++++++++-- 4 files changed, 280 insertions(+), 48 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs index 55f40bf78c..dc2b1ef3b0 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/BrowserWebSocketDuplexStream.cs @@ -195,7 +195,7 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count, { if (_pendingReadOffset >= _pendingRead.Length) { - string next = await ReceiveAsync(_socket).ConfigureAwait(false); + string next = await WaitForReceiveAsync(cancellationToken).ConfigureAwait(false); // A real protocol frame is always at least 8 bytes (4-byte length header + 4-byte serializer id), so // an empty result unambiguously means the JS module resolved the close sentinel (see the 'receive' @@ -216,6 +216,41 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count, return toCopy; } + /// + /// Awaits the JS-side receive() promise while honoring , even + /// though the promise itself has no cancellation hook across the interop boundary. + /// + /// + /// Without this, a caller that cancels a pending read (e.g. + /// racing a timeout, or a shutdown path) would hang until the peer either sends more data or closes the + /// socket - on browser-wasm, the very runtime this transport exists for, that would be an unrecoverable + /// hang. This races the receive against the token and throws as + /// soon as it fires. The JS promise itself is left pending (its eventual resolution is simply discarded) - + /// there is no way to abort it from here - so callers must tear down the connection (which disposes this + /// stream and closes the socket) promptly after observing the cancellation, exactly as they already do for + /// every other cancellation path in this codebase. + /// + private async Task WaitForReceiveAsync(CancellationToken cancellationToken) + { + Task receiveTask = ReceiveAsync(_socket); + if (!cancellationToken.CanBeCanceled) + { + return await receiveTask.ConfigureAwait(false); + } + + TaskCompletionSource cancellationTcs = new(TaskCreationOptions.RunContinuationsAsynchronously); + using (cancellationToken.Register(static state => ((TaskCompletionSource)state!).TrySetResult(true), cancellationTcs)) + { + Task completed = await Task.WhenAny(receiveTask, cancellationTcs.Task).ConfigureAwait(false); + if (completed == cancellationTcs.Task) + { + cancellationToken.ThrowIfCancellationRequested(); + } + } + + return await receiveTask.ConfigureAwait(false); + } + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { Send(_socket, Convert.ToBase64String(buffer, offset, count)); diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs index 8f9250b098..9b950f53f7 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/ClientWebSocketDuplexStream.cs @@ -66,7 +66,12 @@ public override void Write(byte[] buffer, int offset, int count) public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { - if (_receiveCount == 0) + // A loop, not recursion: WebSocket.ReceiveAsync frequently completes synchronously when data is already + // buffered (common over loopback), so a recursive retry here would consume a real stack frame per + // zero-byte message with no opportunity for the awaited continuation to yield - a peer that sends many + // consecutive zero-byte messages (deliberately or due to a bug) could drive that recursion arbitrarily + // deep and crash the process with an uncatchable StackOverflowException. A loop has no such bound. + while (_receiveCount == 0) { WebSocketReceiveResult result = await _webSocket.ReceiveAsync(new ArraySegment(_receiveBuffer), cancellationToken).ConfigureAwait(false); if (result.MessageType == WebSocketMessageType.Close) @@ -77,13 +82,13 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count, _receiveOffset = 0; _receiveCount = result.Count; - // A binary frame can legitimately carry zero bytes (e.g. an empty keep-alive); loop rather than - // reporting a false EOF. The framing layer above always reads a bounded number of bytes so this - // cannot spin indefinitely against a well-behaved peer. - if (_receiveCount == 0 && !result.EndOfMessage) - { - return await ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); - } + // A binary frame (or an individual fragment of one) can legitimately carry zero bytes (e.g. an + // empty keep-alive, or a zero-byte fragment followed by more fragments); loop rather than reporting + // a false EOF. Only a Close frame (handled above) means the peer actually disconnected - a + // zero-byte non-Close result, whether or not it is the final fragment of its message, must not be + // returned as 0 (which Stream.Read/ReadAsync conventionally means EOF). The framing layer above + // always reads a bounded number of bytes so this cannot spin indefinitely against a well-behaved + // peer. } int toCopy = Math.Min(count, _receiveCount); diff --git a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs index c04699781c..735293ff5a 100644 --- a/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs +++ b/src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/Transport/DotnetTestWebSocketClient.cs @@ -159,25 +159,25 @@ public async Task RequestReplyAsync(TRequest req throw; } - object? response = await ReadNextMessageAsync(_stream, cancellationToken).ConfigureAwait(false); - if (response is null) + object? response; + try { - if (!_exitProcessOnConnectionLoss) - { - throw new IOException("The WebSocket transport was closed by the peer before a response was received."); - } - - try - { - await Console.Error.WriteLineAsync($"[DotnetTestWebSocketClient] The WebSocket transport was closed by the peer before a response was received. The peer process likely exited or was killed. Terminating with exit code {(int)ExitCode.GenericFailure}.").ConfigureAwait(false); - } - catch (Exception ex) when (ex is IOException or ObjectDisposedException or InvalidOperationException or NotSupportedException or ArgumentException or OperationCanceledException) - { - // Best-effort diagnostic only; never let logging failures shadow the original problem. - } + response = await ReadNextMessageAsync(_stream, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) when (ex is IOException or ObjectDisposedException or WebSocketException) + { + // Unlike a named pipe (which reports a clean disconnect as a 0-byte read, i.e. a null response + // below), an abrupt WebSocket disconnect - e.g. the peer's process being killed mid-response, + // before it can complete the WebSocket close handshake - surfaces here as a thrown exception + // instead of a null result. Route it through the same connection-loss handling as a null + // response so both failure shapes are indistinguishable to the caller. + await HandleMissingResponseAsync(ex).ConfigureAwait(false); + throw; // Unreachable: HandleMissingResponseAsync always throws or terminates the process. + } - _environment.Exit((int)ExitCode.GenericFailure); - throw new InvalidOperationException("The WebSocket transport was closed by the peer before a response was received."); + if (response is null) + { + await HandleMissingResponseAsync(cause: null).ConfigureAwait(false); } return (TResponse)response!; @@ -188,6 +188,42 @@ public async Task RequestReplyAsync(TRequest req } } + /// + /// Reacts to the transport being closed by the peer before a response was received - whether observed as a + /// null/EOF read or as a thrown transport exception (see the two callers in + /// ). Mirrors 's identical + /// connection-loss policy: when the primary data channel (exitProcessOnConnectionLoss: true) loses its + /// peer there is no way to recover, so the process exits abnormally after a best-effort diagnostic; an + /// auxiliary channel (exitProcessOnConnectionLoss: false) instead always throws so the caller can react + /// cooperatively. + /// + /// Never returns normally: either throws, or terminates the process via _environment.Exit. + private async Task HandleMissingResponseAsync(Exception? cause) + { + if (!_exitProcessOnConnectionLoss) + { + throw new IOException("The WebSocket transport was closed by the peer before a response was received.", cause); + } + + // Surface a diagnostic on stderr so the user has a chance to understand why this process is exiting. We + // deliberately use Console.Error (and not stdout) to avoid corrupting any machine-readable output that + // may be flowing through stdout. + try + { + await Console.Error.WriteLineAsync($"[DotnetTestWebSocketClient] The WebSocket transport was closed by the peer before a response was received. The peer process likely exited or was killed. Terminating with exit code {(int)ExitCode.GenericFailure}.").ConfigureAwait(false); + } + catch (Exception ex) when (ex is IOException or ObjectDisposedException or InvalidOperationException or NotSupportedException or ArgumentException or OperationCanceledException) + { + // Best-effort diagnostic only; never let logging failures shadow the original problem. + } + + _environment.Exit((int)ExitCode.GenericFailure); + + // _environment.Exit normally terminates the process and never returns. Guard against alternate + // IEnvironment implementations (e.g. tests) that don't terminate by throwing explicitly. + throw new InvalidOperationException("The WebSocket transport was closed by the peer before a response was received.", cause); + } + public void Dispose() { if (_disposed) diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs index 93e9b73610..eef36d6240 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/IPC/DotnetTestWebSocketClientTests.cs @@ -62,13 +62,6 @@ public void BuildAuthenticatedUri_InsertsTokenBeforeFragment() } #if NET - // Exercises the full stack end-to-end over a real loopback socket: DotnetTestWebSocketClient.ConnectAsync - // (with the auth token propagated as a query parameter) and ClientWebSocketDuplexStream framing, using the - // real HandshakeMessage/HandshakeMessageSerializer wire types. The "server" side is a minimal hand-rolled - // RFC 6455 opening handshake (HttpListener's WebSocket support is Windows-only, so it cannot be used here) - // followed by System.Net.WebSockets.WebSocket.CreateFromStream, then reads/writes frames manually using the - // documented wire format (int32 payload length + int32 serializer id + body) so this test does not depend on - // NamedPipeConnectionBase (whose framing is already covered directly by the named-pipe transport tests). [TestMethod] [Timeout(30_000, CooperativeCancellation = true)] public async Task ConnectAsync_RequestReplyAsync_RoundTripsRealFramingOverLoopbackWebSocket() @@ -80,7 +73,7 @@ public async Task ConnectAsync_RequestReplyAsync_RoundTripsRealFramingOverLoopba { int port = ((IPEndPoint)listener.LocalEndpoint).Port; - Task<(HandshakeMessage Received, string RequestLine)> serverTask = AcceptAndHandleOneRequestAsync(listener, cts.Token); + Task<(HandshakeMessage Received, string RequestLine)> serverTask = AcceptReadAndReplyAsync(listener, new Dictionary { [9] = "negotiated-value" }, cts.Token); IEnvironment environment = new Mock().Object; DotnetTestWebSocketClient client = new(new Uri($"ws://127.0.0.1:{port}/dotnettest"), "s3cr3t-token", environment, exitProcessOnConnectionLoss: false); @@ -115,30 +108,193 @@ public async Task ConnectAsync_RequestReplyAsync_RoundTripsRealFramingOverLoopba } } - private static async Task<(HandshakeMessage Received, string RequestLine)> AcceptAndHandleOneRequestAsync(TcpListener listener, CancellationToken cancellationToken) + [TestMethod] + [Timeout(30_000, CooperativeCancellation = true)] + public async Task ConnectAsync_RequestReplyAsync_RoundTripsLargeMessageSpanningMultipleWebSocketReceives() + { + // ClientWebSocketDuplexStream's internal receive buffer is 8192 bytes. A property value comfortably + // larger than that forces NamedPipeConnectionBase.ReadNextMessageAsync to pull the frame across several + // WebSocket receives instead of a single one, exercising the offset/count buffering carried across + // ReadAsync calls (_receiveOffset/_receiveCount) that the single-frame round-trip test above never + // needs to touch. + string largeValue = new('x', 50_000); + + using CancellationTokenSource cts = new(TimeSpan.FromSeconds(25)); + TcpListener listener = new(IPAddress.Loopback, 0); + listener.Start(); + try + { + int port = ((IPEndPoint)listener.LocalEndpoint).Port; + + Task<(HandshakeMessage Received, string RequestLine)> serverTask = AcceptReadAndReplyAsync(listener, new Dictionary { [9] = "ok" }, cts.Token); + + IEnvironment environment = new Mock().Object; + DotnetTestWebSocketClient client = new(new Uri($"ws://127.0.0.1:{port}/dotnettest"), "s3cr3t-token", environment, exitProcessOnConnectionLoss: false); + RegisterSerializerViaReflection(client, new HandshakeMessageSerializer(), typeof(HandshakeMessage)); + + try + { + await client.ConnectAsync(cts.Token); + + HandshakeMessage sent = new(new Dictionary { [0] = largeValue }); + HandshakeMessage response = await client.RequestReplyAsync(sent, cts.Token); + Assert.AreEqual("ok", response.Properties?[9]); + + (HandshakeMessage received, _) = await serverTask; + Assert.AreEqual(largeValue, received.Properties?[0]); + } + finally + { + client.Dispose(); + } + } + finally + { + listener.Stop(); + } + } + + [TestMethod] + [Timeout(30_000, CooperativeCancellation = true)] + public async Task RequestReplyAsync_WhenServerClosesWithoutResponding_ThrowsIOException_WhenExitProcessOnConnectionLossIsFalse() + { + using CancellationTokenSource cts = new(TimeSpan.FromSeconds(25)); + TcpListener listener = new(IPAddress.Loopback, 0); + listener.Start(); + try + { + int port = ((IPEndPoint)listener.LocalEndpoint).Port; + + Task serverTask = AcceptReadAndDisconnectWithoutRespondingAsync(listener, cts.Token); + + IEnvironment environment = new Mock().Object; + + // exitProcessOnConnectionLoss: false mirrors how DotnetTestConnection opens auxiliary channels: a + // dropped connection must surface as an exception the caller can handle, not kill the process. This + // is the WebSocket-transport counterpart of NamedPipeClient's identical behavior for exitProcessOnConnectionLoss: false. + DotnetTestWebSocketClient client = new(new Uri($"ws://127.0.0.1:{port}/dotnettest"), "s3cr3t-token", environment, exitProcessOnConnectionLoss: false); + RegisterSerializerViaReflection(client, new HandshakeMessageSerializer(), typeof(HandshakeMessage)); + + try + { + await client.ConnectAsync(cts.Token); + + HandshakeMessage sent = new(new Dictionary { [0] = "1234" }); + await Assert.ThrowsExactlyAsync(() => client.RequestReplyAsync(sent, cts.Token)); + + // IEnvironment.Exit must never have been called: with exitProcessOnConnectionLoss: false a + // connection loss is the caller's problem to handle, not a reason to terminate the process. + Mock.Get(environment).Verify(e => e.Exit(It.IsAny()), Times.Never); + + await serverTask; + } + finally + { + client.Dispose(); + } + } + finally + { + listener.Stop(); + } + } + + [TestMethod] + [Timeout(30_000, CooperativeCancellation = true)] + public async Task RequestReplyAsync_WhenCancelled_ThrowsOperationCanceledExceptionAndDoesNotHang() + { + using CancellationTokenSource testCts = new(TimeSpan.FromSeconds(25)); + TcpListener listener = new(IPAddress.Loopback, 0); + listener.Start(); + try + { + int port = ((IPEndPoint)listener.LocalEndpoint).Port; + + // The server accepts the connection and completes the WebSocket handshake, but then deliberately + // never reads the request or sends a reply - holding the connection open so RequestReplyAsync would + // otherwise wait forever. This isolates cancellation of the read from a peer disconnect (already + // covered by the test above): the connection stays healthy, only the caller's token fires. + Task serverAcceptTask = AcceptAndCompleteHandshakeOnlyAsync(listener, testCts.Token); + + IEnvironment environment = new Mock().Object; + DotnetTestWebSocketClient client = new(new Uri($"ws://127.0.0.1:{port}/dotnettest"), "s3cr3t-token", environment, exitProcessOnConnectionLoss: false); + RegisterSerializerViaReflection(client, new HandshakeMessageSerializer(), typeof(HandshakeMessage)); + + try + { + await client.ConnectAsync(testCts.Token); + + using CancellationTokenSource requestCts = new(TimeSpan.FromMilliseconds(200)); + HandshakeMessage sent = new(new Dictionary { [0] = "1234" }); + + // Not ThrowsExactlyAsync: cancelling a pending Stream read/write typically surfaces as + // TaskCanceledException (a subclass of OperationCanceledException), not the base type itself - + // same convention used elsewhere in this test project (e.g. TaskExtensionsTests). + await Assert.ThrowsAsync(() => client.RequestReplyAsync(sent, requestCts.Token)); + } + finally + { + client.Dispose(); + using TcpClient serverClient = await serverAcceptTask; + } + } + finally + { + listener.Stop(); + } + } + + private static Task<(HandshakeMessage Result, string RequestLine)> AcceptReadAndReplyAsync(TcpListener listener, Dictionary replyProperties, CancellationToken cancellationToken) + => AcceptAndHandleAsync( + listener, + async (stream, requestPayload, cancellationToken) => + { + int serializerId = BitConverter.ToInt32(requestPayload, 0); + Assert.AreEqual(HandshakeMessageFieldsId.MessagesSerializerId, serializerId); + + using MemoryStream requestBody = new(requestPayload, 4, requestPayload.Length - 4); + HandshakeMessageSerializer serializer = new(); + var received = (HandshakeMessage)ProtocolSerializerTestHelper.Deserialize(serializer, requestBody); + + HandshakeMessage reply = new(replyProperties); + using MemoryStream replyBody = new(); + ProtocolSerializerTestHelper.Serialize(serializer, reply, replyBody); + await WriteFrameAsync(stream, HandshakeMessageFieldsId.MessagesSerializerId, replyBody.ToArray(), cancellationToken); + + return received; + }, + cancellationToken); + + private static Task AcceptReadAndDisconnectWithoutRespondingAsync(TcpListener listener, CancellationToken cancellationToken) + => AcceptAndHandleAsync( + listener, + (_, _, _) => Task.FromResult(null), + cancellationToken); + + // Shared plumbing for the server-side half of a loopback test: accepts one connection, completes the RFC + // 6455 handshake, reads exactly one request frame, hands it to (which + // may reply, or not - see the two callers above), then closes the connection. Factored out so each scenario + // only needs to express what differs about the server's reaction to the request. + private static async Task<(T Result, string RequestLine)> AcceptAndHandleAsync(TcpListener listener, Func> handleRequestAsync, CancellationToken cancellationToken) { using TcpClient tcpClient = await listener.AcceptTcpClientAsync(cancellationToken); NetworkStream networkStream = tcpClient.GetStream(); - string requestText = await CompleteServerHandshakeAsync(networkStream, cancellationToken); + string requestLine = await CompleteServerHandshakeAsync(networkStream, cancellationToken); using var serverSocket = WebSocket.CreateFromStream(networkStream, isServer: true, subProtocol: null, keepAliveInterval: Timeout.InfiniteTimeSpan); ClientWebSocketDuplexStream stream = new(serverSocket); byte[] requestPayload = await ReadFrameAsync(stream, cancellationToken); - int serializerId = BitConverter.ToInt32(requestPayload, 0); - Assert.AreEqual(HandshakeMessageFieldsId.MessagesSerializerId, serializerId); - - using MemoryStream requestBody = new(requestPayload, 4, requestPayload.Length - 4); - HandshakeMessageSerializer serializer = new(); - var received = (HandshakeMessage)ProtocolSerializerTestHelper.Deserialize(serializer, requestBody); - - HandshakeMessage reply = new(new Dictionary { [9] = "negotiated-value" }); - using MemoryStream replyBody = new(); - ProtocolSerializerTestHelper.Serialize(serializer, reply, replyBody); - await WriteFrameAsync(stream, HandshakeMessageFieldsId.MessagesSerializerId, replyBody.ToArray(), cancellationToken); + T result = await handleRequestAsync(stream, requestPayload, cancellationToken); + return (result, requestLine); + } - return (received, requestText); + private static async Task AcceptAndCompleteHandshakeOnlyAsync(TcpListener listener, CancellationToken cancellationToken) + { + TcpClient tcpClient = await listener.AcceptTcpClientAsync(cancellationToken); + await CompleteServerHandshakeAsync(tcpClient.GetStream(), cancellationToken); + return tcpClient; } // Minimal RFC 6455 server-side opening handshake: read the HTTP request line + headers (up to the blank From 554fb6bc18f674add0a969f6b07184c42d440cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 21 Jul 2026 17:48:07 +0200 Subject: [PATCH 03/20] Fix independent review findings: secret leak in diagnostics, browser write cancellation Addresses 3 findings from an independent review of commit 6472e529: 1. Secret leak (High): TestApplication.LogInformationAsync logged the raw --diagnostic command-line arguments verbatim, including the value following --dotnet-test-websocket-token, contradicting protocol doc SS15.4. Added CommandLineArgumentsRedactor, a reusable formatter that masks the token value in both space-separated and --option=value/--option:value inline forms (handling a missing value and a repeated option), while preserving every other argument exactly. Wired into the one call site that logs command-line arguments. New CommandLineArgumentsRedactorTests proves the token is absent and the placeholder is present across all these shapes. 2. Empty final message treated as EOF (Medium/High): already fixed by the prior "Address code review findings" commit (ClientWebSocketDuplexStream now loops on any zero-length non-Close result, not just non-final fragments) - re-verified, no further change needed here. 3. Browser cancellation (High): BrowserWebSocketDuplexStream.ReadAsync already honored CancellationToken (added in the prior commit); WriteAsync did not. Since WebSocket.send() in the JS module is synchronous (queues the frame and returns immediately), there is no in-flight operation to race - added an upfront ThrowIfCancellationRequested() so an already-cancelled token is still observed before doing the uncancellable-once-issued send. Also closed a message-loss gap in the existing read-cancellation path: on cancellation, the abandoned JS receive() promise is now explicitly cleared via a new cancelReceive JS function, so a message the peer sends afterward is queued for the next receive() call instead of silently resolving (and being discarded by) the stale, abandoned one. Verified via `dotnet build` (net8.0/net9.0) and `dotnet publish -r browser-wasm` (via samples/BrowserPlayground) that the JS interop signatures remain valid for the wasm JS-interop source generator; true behavioral testing of the JS cancellation path requires the SDK-side WebSocket gateway (not part of this repo) to drive it end-to-end under a real browser/node runtime, so this residual gap is now documented precisely in doc SS15.6 rather than silently left unstated. Also updated docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md: - SS15.3: added a CSP caveat - the data: URL dynamic import requires the page's Content-Security-Policy to permit it; the prior "no additional assets" claim was correct but incomplete under a strict script-src. - SS15.4: documented that the diagnostic log redaction now also covers the raw --dotnet-test-websocket-token command-line argument, not just the connection URI. - SS15.6: documented the exact residual testing gap for the browser JS cancellation path. Full solution build (.\build.cmd -c Debug) green. Microsoft.Testing.Platform.UnitTests: 1469 tests passing (was 1459; +10 new CommandLineArgumentsRedactorTests). dotnet publish -r browser-wasm (samples/BrowserPlayground) succeeds, confirming the browser JS-interop signatures compile/link correctly for browser-wasm. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 282499c0-c68f-41eb-890a-ad47bb78ce54 --- .../004-protocol-dotnet-test-pipe.md | 31 ++++- .../Builder/TestApplication.cs | 2 +- .../CommandLineArgumentsRedactor.cs | 121 ++++++++++++++++++ .../InternalAPI/InternalAPI.Unshipped.txt | 2 + .../Transport/BrowserWebSocketDuplexStream.cs | 47 ++++++- .../CommandLineArgumentsRedactorTests.cs | 108 ++++++++++++++++ 6 files changed, 303 insertions(+), 8 deletions(-) create mode 100644 src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineArgumentsRedactor.cs create mode 100644 test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineArgumentsRedactorTests.cs diff --git a/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md b/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md index 8a37c17c3f..af116af759 100644 --- a/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md +++ b/docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md @@ -768,6 +768,16 @@ fragmented on the wire by the peer or an intermediary. `console.*`). The companion JS module is embedded as a string constant and imported via a `data:` URL, so no changes to the generated wasm bootstrap or published asset set are required. +> [!NOTE] +> **CSP caveat.** The `data:` URL dynamic import relies on the page's Content-Security-Policy permitting it. +> A strict `script-src` that omits `data:` (and lacks `'unsafe-inline'`/a matching `'nonce-'`/`'sha256-'` +> hash for the embedded module, or `'strict-dynamic'`) will block the import, and the WebSocket transport will +> fail to initialize on that page. This is a real constraint under a locked-down CSP, not merely a theoretical +> one - "no additional assets are required" (above) is true for the wasm bootstrap/publish output, but it is +> not the same as "works under any CSP". A future revision could ship the module as a conventional `.js` asset +> (with a `nonce`/hash-friendly `