From 62638f0df93009d36ba4669c109800367f28eaf1 Mon Sep 17 00:00:00 2001 From: Jakub Jares Date: Tue, 14 Jul 2026 12:17:30 +0200 Subject: [PATCH 1/2] Set an explicit reflection-based TypeInfoResolver on the STJ options Test projects that set JsonSerializerIsReflectionEnabledByDefault=false put that switch into their runtimeconfig.json, which testhost runs under. With TypeInfoResolver left null, System.Text.Json falls back to the implicit default resolver that the switch disables, so testhost throws while deserializing the first protocol message and dies, and the runner waits out the whole connection timeout and reports "Failed to negotiate protocol, waiting for response timed out". Assigning an explicit DefaultJsonTypeInfoResolver keeps reflection-based serialization working regardless of the switch. This is the minimal servicing fix for 18.8.1, main and rel/18.9 already resolve this as part of the larger NativeAOT work in #16045. Also bump VersionPrefix to 18.8.1. Fixes #16274. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/Versions.props | 2 +- .../JsonDataSerializer.Stj.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index bcede45c76..92dd2b3fcf 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -14,7 +14,7 @@ from appending +, which breaks DTAAgent. --> false - 18.8.0 + 18.8.1 release diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.Stj.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.Stj.cs index 6d7b2f8dcb..f6c46815ab 100644 --- a/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.Stj.cs +++ b/src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.Stj.cs @@ -8,6 +8,7 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization; using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; @@ -74,6 +75,11 @@ static JsonDataSerializer() NumberHandling = JsonNumberHandling.AllowReadingFromString, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, ReferenceHandler = ReferenceHandler.IgnoreCycles, + // Assign an explicit reflection-based resolver. When TypeInfoResolver is null, STJ falls back to + // the implicit default resolver which is disabled when a test project sets + // JsonSerializerIsReflectionEnabledByDefault=false (that switch flows into the testhost runtimeconfig), + // making testhost throw while deserializing the first protocol message and the runner time out. See #16274. + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), }; private static partial (int version, string? messageType) ParseHeaderFromJson(string rawMessage) From 8f0f9335f1d5e6a9e62e68c8adca8a608471bf2d Mon Sep 17 00:00:00 2001 From: Jakub Jares Date: Tue, 14 Jul 2026 13:01:56 +0200 Subject: [PATCH 2/2] Re-trigger CI (flaky RunSettingsManager singleton test on ubuntu leg) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>