Conversation
) * Fix 50 failing serialization tests after STJ migration - Fix TestPropertyConverter.Read() to use TestProperty.Find() before Register() to avoid type conflicts with pre-registered properties - Create TestCaseConverterV2 and TestResultConverterV2 for v2 protocol that serialize flat properties matching Newtonsoft DataContract output - Create TestObjectBaseConverterFactory for TestObject-derived types that only serializes the property bag as 'Properties' - Create AttachmentSetConverter and UriDataAttachmentConverter for types lacking parameterless constructors with read-only properties - Create TestExecutionContextConverter to exclude [IgnoreDataMember] properties from serialization - Use JavaScriptEncoder.UnsafeRelaxedJsonEscaping to match Newtonsoft's non-HTML-encoding behavior for characters like >, &, backtick - Fix DateTimeOffset format in TestResultConverter.Write() to use STJ's native formatting (omits trailing zero fractional seconds) - Update v2 test JSON in TestResultSerializationTests to use v2 format Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: migrate from Newtonsoft.Json to System.Text.Json Replaces Newtonsoft.Json with System.Text.Json across the entire vstest serialization infrastructure: Core changes: - JsonDataSerializer: rewritten to use JsonSerializerOptions + System.Text.Json - Message.Payload: JToken? -> JsonElement? (public API breaking change) - All custom converters rewritten (TestCase, TestResult, TestObject, TestProperty, TestRunStatistics, AttachmentSet, UriDataAttachment, TestExecutionContext) - Contract resolvers replaced with converter-based options configuration - DotnetTestHostManager: JObject/JToken -> JsonDocument/JsonElement Package references: - Removed Newtonsoft.Json 13.0.3 from all src and test projects - Added System.Text.Json 8.0.5 for net462/netstandard2.0 targets - Updated packaging projects (CLI, Portable, TestPlatform) Behavioral differences from Newtonsoft: - Circular references: writes null instead of {} (IgnoreCycles) - AllowTrailingCommas and ReadCommentHandling enabled for compatibility - UnsafeRelaxedJsonEscaping for consistent character encoding Tests: - All 229 CommunicationUtilities unit tests passing - Added 16 golden baseline serialization comparison tests - Added V2 converters for TestCase and TestResult Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: use raw string literals for JSON in golden tests Replace escaped JSON string literals with C# 11 raw string literals (triple-quote) and pretty-print the JSON for readability. Update AssertJsonEqual to normalize whitespace before comparing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add per-message wire-format serialization tests Add one test file per MessageType covering the most used messages: - VersionCheck (int payload, protocol handshake) - TestMessage (TestMessagePayload, log output) - TestCasesFound (List<TestCase>, discovery results) - DiscoveryComplete (DiscoveryCompletePayload) - StartTestExecutionWithSources (TestRunCriteriaWithSources) - ExecutionComplete (TestRunCompletePayload) - TestRunStatsChange (TestRunStatsPayload) Each file follows the same structure: - Doc comment explaining the message purpose and V1/V7 differences - Realistic example payload with Contoso.Math.Tests scenario - Pretty-printed golden JSON as raw string literals - SerializePayloadV1/V7 tests (exact JSON match) - DeserializePayloadV1/V7 tests (C# property assertions) - RoundTrip tests parameterized by version 8 deserialization tests are skipped (Ignore) pending custom converters for TestRunCompleteEventArgs and TestRunChangedEventArgs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add Newtonsoft reference serializer for comparison and benchmarking Extract the original Newtonsoft.Json serialization implementation into test/NewtonsoftReference/ so we can: - Verify STJ produces identical output to Newtonsoft for every message - Benchmark STJ vs Newtonsoft performance side by side New files: - NewtonsoftReference/NewtonsoftJsonDataSerializer.cs (original hub) - NewtonsoftReference/NewtonsoftMessage.cs, NewtonsoftVersionedMessage.cs - NewtonsoftReference/Serialization/ (all original converters + resolvers) - NewtonsoftReference/NewtonsoftComparisonHelper.cs (comparison utility) Added NewtonsoftComparisonV1/V7 test methods to all 7 per-message test files (14 new tests). All confirm STJ output matches Newtonsoft exactly. 285 total tests, 277 passed, 8 skipped, 0 failed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add performance benchmarks with regression comparison Add SerializationPerformanceTests with: - 24 individual benchmark tests (1000 iterations each) - 4 message types × 3 ops (SerializeV1, SerializeV7, DeserializeV7) × 2 impls - 6 regression comparison tests that run STJ vs Newtonsoft side-by-side and fail if STJ is >2x slower (guards against speed regressions) 30 tests total, 29 passed, 1 skipped (known STJ limitation). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add serialization tests for all remaining MessageTypes + compatibility tests Per-message wire-format tests (16 new files): - StartDiscovery, StartTestExecutionWithTests - CustomTestHostLaunch, CustomTestHostLaunchCallback - LaunchAdapterProcessWithDebuggerAttached + Callback - AttachDebugger, AttachDebuggerCallback - BeforeTestRunStart, AfterTestRunEnd, AfterTestRunEndResult - TestHostLaunched - StartTestSession, StartTestSessionCallback - StopTestSession, StopTestSessionCallback Each follows the standard pattern: golden JSON (V1+V7), serialize, deserialize, round-trip, and Newtonsoft comparison tests. 35 tests are [Ignore]d with explanations — STJ deserialization gaps for types with private setters, mismatched constructor params, or no parameterless constructors. Integration compatibility tests (1 new file): - SerializationCompatibilityTests.cs in Acceptance.IntegrationTests - Tests NEW runner (STJ) ↔ OLD testhosts (Newtonsoft) and vice versa - Uses RunnerCompatibilityDataSource and TesthostCompatibilityDataSource 443 total tests, 408 passed, 35 skipped, 0 failed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: implement 6 custom STJ converters — all tests unskipped Add converters for types STJ couldn't deserialize by default: - TestRunCompleteEventArgsConverter (private ctor + private setters) - TestRunChangedEventArgsConverter (ctor param name mismatch) - AfterTestRunEndResultConverter (private ctor + private setters) - TestProcessAttachDebuggerPayloadConverter (pid vs ProcessID) - TestSessionInfoConverter (Id has private setter) - DiscoveryCriteriaConverter (computed Sources property) All 27 [Ignore] attributes removed. 443 tests, 0 skipped, 0 failed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: add VSTEST_USE_NEWTONSOFT_JSON_SERIALIZER fallback flag Add an environment variable to fall back to the original Newtonsoft.Json serialization at runtime if the System.Text.Json migration causes issues. When VSTEST_USE_NEWTONSOFT_JSON_SERIALIZER=1 is set, JsonDataSerializer delegates all operations to LegacyNewtonsoftJsonDataSerializer, which preserves the original Newtonsoft.Json behavior with JToken-based payload handling and the original contract resolvers/converters. Changes: - Add VSTEST_USE_NEWTONSOFT_JSON_SERIALIZER constant to FeatureFlag.cs - Add Newtonsoft.Json PackageReference to CommunicationUtilities (alongside STJ) - Create LegacyNewtonsoftJsonDataSerializer implementing IDataSerializer - Create Serialization/Legacy/ with original Newtonsoft contract resolvers and converters (TestCase, TestResult, TestObject, TestRunStatistics) - Modify JsonDataSerializer to delegate when the flag is set - Restore Newtonsoft.Json PackageReference in CLI, TestPlatform, Portable packaging projects - Update circular-reference test to handle both serializer behaviors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: add VSTEST_USE_NEWTONSOFT_JSON_SERIALIZER fallback env variable Add a runtime safety valve to revert to the original Newtonsoft.Json serializer if System.Text.Json causes issues in production. Set VSTEST_USE_NEWTONSOFT_JSON_SERIALIZER=1 to activate the fallback. Implementation: - LegacyNewtonsoftJsonDataSerializer with JToken-JsonElement bridging - Serialization/Legacy/ folder with original converters and resolvers - FeatureFlag constant following existing VSTEST_ pattern - JsonDataSerializer delegates to legacy impl when flag is set - Both Newtonsoft.Json and System.Text.Json packaged (dual dependency) Verified: 443/443 tests pass on both STJ (default) and Newtonsoft paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore: remove stray test file * chore: remove Newtonsoft.Json from all shipped packages, migrate samples - Remove Newtonsoft.Json dependency from all .nuspec files (7 files) - Remove Newtonsoft.Json PackageReference from packaging .csproj files - Replace Newtonsoft.Json.dll with System.Text.Json.dll in package contents - Add PrivateAssets=All to CommunicationUtilities Newtonsoft ref (internal fallback only) - Migrate samples/Microsoft.TestPlatform.Protocol to System.Text.Json - Remove unused Newtonsoft.Json from playground project - Update verify-nupkgs.ps1 expected file counts - ObjectModel confirmed clean: no JSON library references build.cmd -pack succeeds, no Newtonsoft.Json.dll in any output package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: unify Message/VersionedMessage into single class Message is now a simple data object with no JSON library dependency: - MessageType (routing key) - Version (protocol version) - RawMessage (raw JSON string, parsed lazily) Removed: VersionedMessage class, VersionedMessageWithRawMessage, MessageHeader, Payload property, DeserializeJsonElement. Added: MessageEnvelope/VersionedMessageEnvelope for serialization. 443/443 tests pass on both STJ and Newtonsoft fallback paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add Newtonsoft fallback and cross-compat tests 28 tests verifying STJ ↔ Newtonsoft interoperability: - IdenticalOutput V1/V7: STJ and Newtonsoft produce identical JSON - CrossCompat STJ→Newtonsoft: new runner → old testhost simulation - CrossCompat Newtonsoft→STJ: old runner → new testhost simulation Covers: TestMessage, VersionCheck, TestCasesFound, DiscoveryComplete, ExecutionComplete, TestRunStatsChange, StartTestExecutionWithSources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Embed Jsonite source and add comparison tests - Download Jsonite.cs (BSD-2-Clause, by xoofx) from https://github.com/xoofx/jsonite and embed it at src/.../Json/Jsonite/Jsonite.cs with license header and pragma warning suppressions for our analyzers. - Add JsoniteSerializer wrapper in the test project for parsing/serializing JSON via the Jsonite object-graph API. - Add JsoniteComparisonTests (36 tests): * Parse fidelity: Jsonite can parse all STJ-produced message JSON. * Round-trip: parse -> re-serialize preserves structure. * Structural correctness: envelope fields (MessageType, Version, Payload) are present and correct. * Performance: parse/round-trip timing vs STJ JsonDocument.Parse. All 507 tests pass (including 36 new Jsonite tests) on net10.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * build fixes * Fix Newtonsoft comparison to be property-order-independent On net48, Newtonsoft serializes DiscoveryCriteria properties in a different order than STJ (e.g. Package after RunSettings vs first). The NormalizeJson helper was only collapsing whitespace but preserving property order, causing NewtonsoftComparisonV7 to fail. Sort object properties alphabetically (recursively) during normalization so the comparison is order-independent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add deps * remove debug * fixup some deps * redirect * fixes * fix: TestRunStatisticsConverter handles private Stats setter TestRunStatistics.Stats has a private setter which STJ cannot populate. The converter now manually deserializes Stats as a Dictionary and uses the constructor that accepts it, fixing NullReferenceException in ParallelRunDataAggregator.GetAggregatedRunStats during test execution. Also made the converter internal (was incorrectly public) and removed stale PublicAPI.Shipped.txt entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: add ObjectConverter for primitive deserialization in IDictionary<string, object> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * f * fix: MSTEST0037 analyzer violations in SerializationCompatibilityTests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve MSB3277 System.Text.Json assembly version conflicts Add explicit System.Text.Json PackageReference to projects that get it transitively via CommunicationUtilities/CrossPlatEngine. On net8.0/net9.0, the framework-provided STJ (v8/v9) conflicts with the NuGet v10.0.5 used by CommunicationUtilities. Making STJ a direct PackageReference ensures the NuGet version is primary and resolves the conflict. Also remove unused Newtonsoft.Json.Linq using directive in VsTestConsoleRequestSenderTests and update NuGet package file counts in verify-nupkgs.ps1 to account for the STJ migration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use Jsonite on .NET Framework, System.Text.Json on modern .NET Replace System.Text.Json with embedded Jsonite on net462 to eliminate dependency conflicts on .NET Framework. System.Text.Json remains the serializer for netstandard2.0 (consumed by .NET Core/5+ hosts). Changes: - Make System.Text.Json PackageReference conditional (non-NETFRAMEWORK only) - Exclude STJ converter files from net462 compilation - Add #if NETFRAMEWORK blocks in JsonDataSerializer to use Jsonite for serialization/deserialization on .NET Framework - Create JsoniteConvert helper: reflection-based converter between Jsonite untyped objects (JsonObject/JsonArray) and strongly-typed .NET objects - Wrap [JsonConstructor] attributes in #if !NETFRAMEWORK conditionals - Move STJ converter public API entries to netstandard2.0-specific file The Jsonite path handles cycle detection, depth limiting, and safe traversal of framework types. TestCase trait serialization parity is a known gap to be addressed in follow-up work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: Jsonite private setter handling via GetSetMethod(nonPublic: true) PropertyInfo.SetValue fails silently on private setters. Use GetSetMethod() to check for public setter, fall back to backing field, then to private setter via GetSetMethod(nonPublic: true). Fixes TestRunStatistics.Stats not being populated on net462. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: Jsonite handles read-only collection properties via Add() Collections like TestResult.Messages and TestResult.Attachments have no setter — they're initialized in the constructor. Jsonite now detects IList properties without setters and adds items to the existing collection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: Assert param order in perf regression + cross-compat tests MSTest v4 API: (expected, actual) not (actual, expected) - Assert.IsLessThanOrEqualTo(upperBound, value) - Assert.Contains(expectedItem, collection) 507/507 net10.0 tests now pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: add Jsonite type-specific serializers for vstest objects Custom serialization handlers for TestCase, TestResult, TestProperty, AttachmentSet, UriDataAttachment, TestResultMessage. Also handles DataContract types by respecting [IgnoreDataMember] and skipping delegates. net10.0: 507/507 ✅ | net48: 418/507 (up from 396) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: full Jsonite converter suite for .NET Framework net10.0: 507/507 | net48: 496/507 (11 remaining edge cases) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: version-aware Jsonite serialization, DateTimeOffset format, constructor dedup - Pass version parameter through ToJsonValue for V1/V2 format selection - Fix DateTimeOffset formatting to trim trailing zero fractional seconds - Track constructor-consumed keys to avoid duplicating collection items - Enable AllowTrailingCommas in Jsonite parser - Add version validation on NETFRAMEWORK path - Fix null property value handling to match STJ behavior (T=object) 506 of 507 net48 tests pass. 1 remaining failure is a performance regression flake (Jsonite ~2.67x vs Newtonsoft for simple messages). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: Portable nuspec ships net462 CommunicationUtilities for TestHostNetFramework The TestHostNetFramework in the Portable package was sourcing from net8.0\ (netstandard2.0 build with STJ dependency) instead of net48\ (net462 build with Jsonite). This caused testhost to crash with TypeInitializationException when running on .NET Framework because System.Text.Json was not available. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: use Jsonite for netstandard2.0 too — eliminates STJ version mismatch The netstandard2.0 build was compiled against System.Text.Json 10.x but testhost on .NET 8 only has STJ 8.x built-in, causing TypeInitializationException. Fix: use Jsonite for both net462 AND netstandard2.0. Changed #if !NETFRAMEWORK to #if NETCOREAPP so STJ is only used on actual .NET Core TFMs where it's built-in. Also guards [JsonConstructor] attributes with #if NETCOREAPP. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * redirects * Add binding redirect verification tool Adds eng/verify-binding-redirects.ps1 which verifies that newVersion in bindingRedirect entries matches the actual assembly version of the corresponding DLL in the package. Integrated into verify-nupkgs.ps1 to run automatically after file-count verification. Key features: - Handles XML namespace (urn:schemas-microsoft-com:asm.v1) correctly - Searches config directory and probing privatePath subdirectories - Loads assemblies in subprocess to avoid locking DLLs - Gracefully handles runtime-provided assemblies (INFO, not error) - Normalizes 3-part/4-part version strings for comparison Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: add binding redirect verification tool New eng/verify-binding-redirects.ps1 that: - Finds all .config files with bindingRedirect entries in extracted packages - Gets ALL DLL assembly versions in ONE subprocess (avoids per-DLL process spawn) - Stores results as objects with full path (handles same-name DLLs in different dirs) - Compares newVersion against actual assembly version - Reports mismatches as errors Integrated into verify-nupkgs.ps1 after existing checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: verify-binding-redirects only checks DLLs from redirects, uses temp file - Only get versions for DLLs actually mentioned in binding redirects (not ALL DLLs) - Write paths to temp file instead of command line args (avoids Windows 32K limit) - Parse configs first, collect entries, then one subprocess call for unique DLLs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * still redirects * still redirects * counts * feat: remove direct System.Text.Json usage from DotnetTestHostManager Replace JsonDocument.Parse with Jsonite for runtimeconfig.dev.json parsing on .NET Framework builds. Link Jsonite.cs source from CommunicationUtilities. Note: Microsoft.Extensions.DependencyModel still transitively uses STJ for DependencyContextJsonReader. That's a separate issue. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Replace DependencyContextJsonReader with Jsonite-based DepsJsonParser on .NET Framework Add DepsJsonParser using Jsonite to parse deps.json for .NET Framework builds, eliminating the System.Text.Json transitive dependency via DependencyModel. - Create DepsJsonParser.cs with minimal deps.json parsing (runtime libraries, assembly paths, package path, version) - Conditionally compile: .NET Core keeps DependencyContextJsonReader, .NET Framework uses DepsJsonParser - Make DependencyModel PackageReference conditional on .NETCoreApp - Add comprehensive tests for DepsJsonParser and runtimeconfig.dev.json parsing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: remove System.Text.Json.dll from Portable TestHostNetFramework nuspec No longer needed since net462 and netstandard2.0 use Jsonite instead. Update package file counts in verify-nupkgs.ps1 accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * small fixes * feat: add Newtonsoft.Json dependency detection script New eng/detect-newtonsoft-deps.ps1 scans the solution for: - Direct PackageReference without PrivateAssets=All - Source files using Newtonsoft.Json outside Legacy/ folders - Shipped packages containing Newtonsoft.Json.dll - Unconditional System.Text.Json refs that leak to .NET Framework - Binding redirects for Newtonsoft.Json Safety net to catch accidental re-introduction after STJ/Jsonite migration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: split JsonDataSerializer into partial classes Extract #if NETCOREAPP / #if !NETCOREAPP blocks from JsonDataSerializer.cs into platform-specific partial class files: - JsonDataSerializer.cs: shared logic, zero #if directives, partial method declarations - JsonDataSerializer.Stj.cs: System.Text.Json options, converters, DTOs, implementations - JsonDataSerializer.Jsonite.cs: Jsonite-based implementations + ValidateVersion Reduces 11 inline #if blocks to 0 in the main file. Follows the existing platform abstraction pattern from PlatformAbstractions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: runtime detection for missing Newtonsoft.Json dependency When an extension tries to load Newtonsoft.Json (or other known removed assemblies) and the DLL is not found, emit a one-time user-visible warning identifying which assembly requested it. - Add ReportMissingKnownAssembly to AssemblyResolver.OnResolve - Pass RequestingAssembly through AssemblyResolveEventArgs - One-time per assembly per process (static HashSet dedup) - Warning via TestSessionMessageLogger + EqtTrace - Add NewtonSoftDependencyMissing test asset (ExcludeAssets=runtime) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove Legacy Newtonsoft fallback and stale files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR #15540 review comments Code quality: - Use InvariantCulture + DateTimeStyles.RoundtripKind for wire-format parsing - Deserialize directly from JsonElement (no GetRawText allocations) - DRY up JsonSerializerOptions with CreateBaseOptions + clone pattern - Fix TestObjectConverter nullability typing - Fix PublicAPI.Unshipped.txt entry for ConnectionTimeoutWithErrorMessage - Message.ToString() truncates to length only (no log bloat) File organization: - Move JsoniteConvert.cs under Serialization/ folder - Wrap all STJ serializer files in #if NETCOREAPP - Remove project-level Compile conditions (files self-guard) - Add Jsonite to THIRD-PARTY-NOTICES.txt Package fixes: - Remove STJ from CLI sourcebuild nuspecs - Revert CLI/V2.CLI nuspec changes - Remove STJ packaging from Portable/TestPlatform csproj - Update CLI file count in verify-nupkgs.ps1 Misc: - Fix verify-binding-redirects.ps1: GetAssemblyName + case mismatch - Fix Resources.resx double space typo - Fix sample null handling and empty version Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove stub comment file TestPlatformContractResolver1.cs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert partial #15569 impl and fix SerializePayload test mocks - Revert VsTestConsoleProcessManager/Wrapper timeout changes (ported to #15569 PR) - Fix HandleRawMessageShouldAddVsTestDataPointsIfTelemetryOptedIn mock to match 3-arg SerializePayload Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix unit test failures: message format, serialization order, DiscoveryCriteria - SendMessageWithoutAnyPayload: no Payload field when null (STJ behavior) - DiscoveryCriteria: update expected JSON for STJ property order, roundtrip test - Revert partial #15569 VsTestConsoleProcessManager changes (separate PR) - Fix SerializePayload mock to match 3-arg overload Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert sample protocol changes — standalone, not part of migration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove #if NET from serialization tests — all tests run on both TFMs - Created shared SerializationTestHelpers.cs with AssertJsonEqual/Minify using Newtonsoft JToken normalization (works on all TFMs) - Rewrote NewtonsoftComparisonHelper to use Newtonsoft JToken instead of System.Text.Json JsonDocument, removing the #if NET wrapper - Removed #if NET guards from all 28 serialization test files: - Removed conditional using System.Text.Json directives - Removed #if NET around NewtonsoftComparison test methods - Replaced per-file AssertJsonEqual/Minify with shared helpers - Converted JsonDocument structural assertions to JObject/JToken in TestCaseSerializationTests and TestResultSerializationTests - Replaced NormalizeJson #if blocks in NewtonsoftFallbackTests and SerializationGoldenTests - Ungated STJ perf tests in JsoniteComparisonTests (added System.Text.Json package reference for net48) - All 507 tests pass on net10.0, net9.0, and net48 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix DiscoveryCriteria test: verify properties not exact JSON string Exact JSON comparison breaks across .NET versions due to different escaping and property ordering. Verify key properties are present instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix DiscoveryCriteria test: use Assert.Contains per MSTEST0037 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix perf regression test flake: skip ratio check when baseline < 10ms When Newtonsoft baseline is < 10ms for 1000 iterations, OS scheduling noise makes ratio comparisons unreliable (3ms vs 1ms = 3x 'regression'). Skip the ratio check and log the skip reason. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove DiscoveryCriteria raw STJ test — covered by wire-format tests Raw STJ without DiscoveryCriteriaConverter cannot properly roundtrip DiscoveryCriteria (TimeSpan, FrequencyOfDiscoveredTestsEvent all lose values). The wire-format tests in CommunicationUtilities.UnitTests cover DiscoveryCriteria serialization with the proper converter on both TFMs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix perf tests to use production code path (JsonDataSerializer) Replace raw JsonDocument.Parse/Jsonite.Parse with actual production code: JsonDataSerializer.Instance.SerializePayload/DeserializeMessage/ DeserializePayload. These test what actually runs in vstest, including our custom converters and options. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Exclude perf tests * Add SerializerName diagnostic — reveals netstandard2.0 always uses Jsonite VerifySerializerName test proves that even on net10.0, the production code path uses Jsonite (not STJ) because CommunicationUtilities only compiles for net462;netstandard2.0 — NETCOREAPP is never defined. All #if NETCOREAPP conditionals in this project are dead code. The STJ converters are compiled but never used. To fix: add net8.0 or net10.0 to CommunicationUtilities TargetFrameworks so NETCOREAPP is defined and STJ code path is active on .NET Core. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove all Newtonsoft comparison tests and make converters internal - Delete NewtonsoftReference/ folder and NewtonsoftFallbackTests.cs - Remove NewtonsoftComparison methods from all 23 serialization test files - Remove Regression performance tests (compared with Newtonsoft) - Make TestCaseConverter, TestObjectConverter, TestResultConverter internal - Add net8.0 PublicAPI files for new TFM - Keep Newtonsoft.Json PackageReference (still used for JToken normalization) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add comprehensive serializer comparison tests Tests JsonDataSerializer.Instance (production path) against NewtonsoftJsonDataSerializer for every MessageType on v1 and v7: - SerializePayload, DeserializeMessage, DeserializePayload roundtrip - SerializeMessage (no payload) - Performance comparison (must be on-par or faster) - VerifySerializerName (STJ on .NET Core, Jsonite on .NET Framework) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add roundtrip performance tests with Newtonsoft baseline assertion Performance_RoundTrip_TestMessage and Performance_RoundTrip_ExecutionComplete test full DeserializeMessage + DeserializePayload roundtrip against Newtonsoft baseline, asserting ratio <= 3x. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Move Newtonsoft comparison infra to Serialization/Compatibility All Newtonsoft comparison tests, helpers, and reference serializer moved to Serialization/Compatibility/ for easy future removal. Perf assertions show raw ms on failure instead of ratio. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review findings and fix SerializerSelectionTests - Fix TestCaseConverterV2: use direct JsonElement instead of GetRawText() - Fix bare catch blocks in JsoniteConvert.cs: add EqtTrace.Warning logging - Pass version to JsoniteConvert.To<T>() in DeserializePayloadCore - Fix DiagnosticSource binding redirect version (8.0.0.1 -> 8.0.0.0) - Add serializer name diagnostic logging in JsonDataSerializer - Fix SerializerSelectionTests: enable diag, use correct runner data source, fix Assert.Contains parameter order Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix SendMessage null payload: suppress null Payload in JSON output MessageEnvelope and VersionedMessageEnvelope DTOs now use JsonIgnoreCondition.WhenWritingNull on the Payload property so that SerializeMessageCore produces correct wire format without Payload:null. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix STJ double-for-int in IDictionary<string, object> metrics STJ built-in dictionary converter deserializes JSON integers as double when value type is object, bypassing custom ObjectConverter. Add FixUpObjectDictionaries post-processing in DeserializePayloadCore that converts whole-number doubles back to int for known types with Metrics dictionaries (TestRunCompleteEventArgs, TestRunAttachmentsProcessing- CompleteEventArgs, AfterTestRunEndResult, DiscoveryCompletePayload). Also add ObjectDictionaryConverterFactory and improve ObjectConverter with TryGetInt32 for better numeric type preservation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Retrigger CI (previous build hung in Unit Test step) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add nodereuse:false * noreuse and write message * Fix private setter deserialization for TestCaseEventArgs TestCaseEventArgs.TestCaseId, TestCaseName, IsChildTestCase, TestElement and TestCaseEndEventArgs.TestOutcome had private/internal setters that prevented STJ (and partially Jsonite) from populating them during deserialization. Changed to public setters. Added 26 serialization test files covering all 29 previously untested message types (1095 total serialization tests, all passing). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Jsonite control character crash and add edge case tests Jsonite WriteString threw ArgumentException on control characters < 0x20 (e.g. \u0003 ETX, \u0001 SOH). Now escapes them as \uXXXX instead. Same fix as testfx#5120. Added round-trip edge case tests for: - Control characters (\u0001, \u0003) - Newlines and tabs (\n, \r\n, \t) - Unicode and emoji (CJK, accented chars, surrogate pairs) - Backslashes and quotes (Windows paths with escaped quotes) - Empty strings Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add batch perf tests for 1000-result TestRunStatsChange Tests serialize/deserialize/round-trip a TestRunStatsChange payload with 1000 test results (900 passed, 100 failed with error messages). Each result has traits, code file path, and realistic property values. Observed perf (10 iterations of 1000-result batch): - STJ serialize: ~11ms avg, deserialize: ~60ms avg - Jsonite serialize: ~36ms avg, deserialize: ~96ms avg - JSON size: 911KB per batch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update Microsoft.Internal.TestPlatform.Extensions to 18.3.11611.365 Fixes symbol resolution issues. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert "Update Microsoft.Internal.TestPlatform.Extensions to 18.3.11611.365" This reverts commit cd107fc. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates VSTest’s JSON wire serialization away from Newtonsoft.Json to System.Text.Json (NETCOREAPP) and Jsonite (non-NETCOREAPP), updating the message envelope model and broadening serialization wire-format test coverage while removing Newtonsoft.Json from production packaging paths.
Changes:
- Updates the communication message model to use
Message.Version+Message.RawMessage(deferred payload deserialization) and removesVersionedMessage/Message.Payload. - Introduces/updates serializers and converters (STJ + Jsonite), adds extensive wire-format tests, and updates existing unit/integration/acceptance tests accordingly.
- Removes Newtonsoft.Json from production packages/configs and updates packaging/verification scripts and third-party notices.
Reviewed changes
Copilot reviewed 158 out of 159 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/vstest.ProgrammerTests/Fakes/FakeMessage.cs | Updates debugging helper comment to match Message model changes. |
| test/TestAssets/hanging-child/Program.cs | Adds rationale comments for long sleep used by dump-related tests. |
| test/TestAssets/child-hang/UnitTest1.cs | Adds rationale comments for long sleep used by dump-related tests. |
| test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBuild.cs | Switches checksum JSON to STJ and adds -nodereuse:false to restore/build invocations. |
| test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs | Adds a new using directive (currently appears unused). |
| test/Microsoft.TestPlatform.ObjectModel.UnitTests/Microsoft.TestPlatform.ObjectModel.UnitTests.csproj | Removes Newtonsoft.Json package reference from unit tests project. |
| test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/DiscoveryCriteriaTests.cs | Removes Newtonsoft-based JSON serialization tests for DiscoveryCriteria. |
| test/Microsoft.TestPlatform.Library.IntegrationTests/TranslationLayerTests/CodeCoverageTests.cs | Adjusts telemetry metric numeric assertions post-serializer change. |
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/EventHandlers/TestRequestHandlerTests.cs | Updates tests to construct Message with Version/RawMessage and adjusts serialization helper. |
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs | Updates completion message construction to new message model. |
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyDiscoveryManagerTests.cs | Updates completion message construction to new message model. |
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelRunEventsHandlerTests.cs | Updates mocked messages to carry Version/RawMessage. |
| test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelDiscoveryEventsHandlerTests.cs | Updates mocked messages to carry Version/RawMessage and normalizes BOM in header. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/VersionCheckSerializationTests.cs | Adds wire-format tests for VersionCheck message across V1/V7 envelopes. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestRunAttachmentsProcessingCancelSerializationTests.cs | Adds no-payload wire-format tests for attachment-processing cancel message. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TestHostLaunchedSerializationTests.cs | Adds wire-format tests for TestHostLaunched payload across V1/V7 envelopes. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/TelemetryEventMessageSerializationTests.cs | Adds wire-format tests for telemetry event message. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/StopTestSessionSerializationTests.cs | Adds wire-format tests for StopTestSession payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/SessionStartSerializationTests.cs | Adds wire-format tests for SessionStart (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/SessionEndSerializationTests.cs | Adds wire-format tests for SessionEnd (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/SessionConnectedSerializationTests.cs | Adds wire-format tests for SessionConnected (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/SessionAbortSerializationTests.cs | Adds wire-format tests for SessionAbort (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/ProtocolErrorSerializationTests.cs | Adds wire-format tests for ProtocolError (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/LaunchAdapterProcessWithDebuggerAttachedCallbackSerializationTests.cs | Adds wire-format tests for launch-adapter callback message. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/ExtensionsInitializeSerializationTests.cs | Adds wire-format tests for ExtensionsInitialize payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/ExecutionInitializeSerializationTests.cs | Adds wire-format tests for ExecutionInitialize payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/EditorAttachDebuggerIntSerializationTests.cs | Adds wire-format tests for EditorAttachDebugger (int payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/EditorAttachDebuggerCallbackSerializationTests.cs | Adds wire-format tests for EditorAttachDebuggerCallback payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/EditorAttachDebugger2SerializationTests.cs | Adds wire-format tests for EditorAttachDebugger2 payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/DiscoveryInitializeSerializationTests.cs | Adds wire-format tests for DiscoveryInitialize payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/DataCollectionTestStartAckSerializationTests.cs | Adds wire-format tests for DataCollectionTestStartAck (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/DataCollectionTestEndResultSerializationTests.cs | Adds wire-format tests for DataCollectionTestEndResult payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/DataCollectionMessageSerializationTests.cs | Adds wire-format tests for DataCollectionMessage payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/CustomTestHostLaunchCallbackSerializationTests.cs | Adds wire-format tests for CustomTestHostLaunchCallback payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/SerializationTestHelpers.cs | Adds JSON normalization helpers for tests (via Newtonsoft JToken). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/Serialization/NewtonsoftTestRunStatisticsConverter.cs | Adds extracted Newtonsoft converter for comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/Serialization/NewtonsoftTestPlatformContractResolver1.cs | Adds extracted Newtonsoft resolver for v1 protocol comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/Serialization/NewtonsoftTestObjectConverter.cs | Adds extracted Newtonsoft TestObject converter for comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/Serialization/NewtonsoftDefaultTestPlatformContractResolver.cs | Adds extracted Newtonsoft default resolver for comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/NewtonsoftVersionedMessage.cs | Adds extracted Newtonsoft VersionedMessage for comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/NewtonsoftMessage.cs | Adds extracted Newtonsoft Message for comparison testing. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/Compatibility/NewtonsoftReference/NewtonsoftComparisonHelper.cs | Adds helper to compare current serializer output vs original Newtonsoft output. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/CancelTestRunSerializationTests.cs | Adds wire-format tests for CancelTestRun (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/CancelDiscoverySerializationTests.cs | Adds wire-format tests for CancelDiscovery (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/BeforeTestRunStartResultSerializationTests.cs | Adds wire-format tests for BeforeTestRunStartResult payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/AttachDebuggerSerializationTests.cs | Adds wire-format tests for AttachDebugger payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/AttachDebuggerCallbackSerializationTests.cs | Adds wire-format tests for AttachDebuggerCallback payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/AfterTestRunEndSerializationTests.cs | Adds wire-format tests for AfterTestRunEnd (bool payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Serialization/AbortTestRunSerializationTests.cs | Adds wire-format tests for AbortTestRun (no payload). |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/Microsoft.TestPlatform.CommunicationUtilities.UnitTests.csproj | Adds Newtonsoft.Json and conditional STJ package refs for test utilities. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventSenderTests.cs | Updates mocks to provide RawMessage/Version instead of JToken payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionTestCaseEventHandlerTests.cs | Updates message setup to provide RawMessage/Version instead of JToken payload. |
| test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/DataCollectionRequestSenderTests.cs | Updates deserialized message stubs to no longer require explicit Payload = null. |
| test/Microsoft.TestPlatform.CommunicationUtilities.Platform.UnitTests/SocketCommunicationManagerTests.cs | Updates expectations to new message behavior (RawMessage populated, no eager Payload). |
| test/Microsoft.TestPlatform.Client.UnitTests/Execution/TestRunRequestTests.cs | Updates mock verification to include protocol version param in SerializePayload. |
| test/Microsoft.TestPlatform.Client.UnitTests/Discovery/DiscoveryRequestTests.cs | Updates mock verification to include protocol version param in SerializePayload. |
| test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/Microsoft.TestPlatform.AdapterUtilities.UnitTests.csproj | Removes Newtonsoft.Json reference from adapter utilities unit tests. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/SerializerSelectionTests.cs | Adds acceptance tests asserting serializer selection by runner TFM via diag logs. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetHostArchitectureVerifierTests.cs | Switches runtimeconfig patching to System.Text.Json.Nodes. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetArchitectureSwitchTests.Windows.cs | Switches runtimeconfig patching to System.Text.Json.Nodes. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/BlameDataCollectorTests.cs | Removes explicit /diag argument usage in blame test. |
| src/vstest.console/app.config | Removes Newtonsoft redirect and updates binding redirects; keeps DiagnosticSource redirect. |
| src/testhost.x86/app.config | Removes Newtonsoft redirect and adjusts binding redirect set. |
| src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec | Stops shipping Newtonsoft.Json.dll in package output. |
| src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.csproj | Removes Newtonsoft.Json package reference/copy step from packaging project. |
| src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.nuspec | Removes Newtonsoft.Json dependency from testhost package group. |
| src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.nuspec | Removes Newtonsoft.Json files and adjusts TestHostNetFramework CommunicationUtilities source. |
| src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj | Removes Newtonsoft.Json package reference/copy step from portable packaging project. |
| src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec | Removes Newtonsoft.Json content file from sourcebuild product nuspec. |
| src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec | Removes Newtonsoft.Json content file from sourcebuild nuspec. |
| src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec | Removes Newtonsoft.Json content file from CLI package. |
| src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj | Removes Newtonsoft.Json package reference/copy step from CLI packaging project. |
| src/datacollector/app.config | Removes Newtonsoft redirect and adjusts binding redirects. |
| src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/Microsoft.TestPlatform.VsTestConsole.TranslationLayer.nuspec | Removes Newtonsoft.Json dependencies from translation layer nuspec. |
| src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj | Removes Newtonsoft.Json ref and links Jsonite source for non-NETCOREAPP builds. |
| src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs | Replaces Newtonsoft parsing; uses STJ on NETCOREAPP and Jsonite/DepsJsonParser elsewhere. |
| src/Microsoft.TestPlatform.TestHostProvider/Hosting/DepsJsonParser.cs | Adds minimal Jsonite-based deps.json parser for non-NETCOREAPP. |
| src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Unshipped.txt | Declares newly-public setters for serialization compatibility. |
| src/Microsoft.TestPlatform.ObjectModel/DataCollector/Events/TestCaseEvents.cs | Makes several setters public to support serialization across serializers. |
| src/Microsoft.TestPlatform.Extensions.TrxLogger/Microsoft.TestPlatform.Extensions.TrxLogger.nuspec | Removes Newtonsoft.Json dependency from TRX logger nuspec. |
| src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessCodeMethods.cs | Fixes incorrect method name in trace message (Linux → Windows). |
| src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs | Comment typo introduced in updated line. |
| src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs | Removes dead commented code referencing VersionedMessage. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestSessionInfoConverter.cs | Adds STJ converter for TestSessionInfo (private setter handling). |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunStatisticsConverter.cs | Replaces Newtonsoft converter with STJ converter for ITestRunStatistics. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunCompleteEventArgsConverter.cs | Adds STJ converter for TestRunCompleteEventArgs (private constructor/setters). |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestRunChangedEventArgsConverter.cs | Adds STJ converter for TestRunChangedEventArgs to match constructor binding. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestPropertyConverter.cs | Adds STJ converter for TestProperty without delegate serialization. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestProcessAttachDebuggerPayloadConverter.cs | Adds STJ converter for payload with ctor parameter mismatch. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectBaseConverter.cs | Adds STJ converter factory for TestObject-derived types serializing property bag only. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestExecutionContextConverter.cs | Adds STJ converter matching DataContract behavior for execution context. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestCaseConverterV2.cs | Adds STJ V2 TestCase converter (flat core fields + custom properties). |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/ObjectConverter.cs | Adds object/dictionary converter to deserialize primitives instead of JsonElement. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DiscoveryCriteriaConverter.cs | Adds STJ converter for DiscoveryCriteria with reflection-based private setters. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/DefaultTestPlatformContractResolver.cs | Removes old Newtonsoft contract resolver implementation. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/AttachmentConverters.cs | Adds STJ converters for AttachmentSet/UriDataAttachment. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/AfterTestRunEndResultConverter.cs | Adds STJ converter for AfterTestRunEndResult. |
| src/Microsoft.TestPlatform.CommunicationUtilities/PublicAPI/PublicAPI.Shipped.txt | Updates public API surface: removes Newtonsoft-facing entries; adds RawMessage/Version. |
| src/Microsoft.TestPlatform.CommunicationUtilities/ProtocolVersioning.cs | Updates comments to reflect Version field in Message instead of VersionedMessage type. |
| src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithTests.cs | Uses STJ [JsonConstructor] under NETCOREAPP. |
| src/Microsoft.TestPlatform.CommunicationUtilities/ObjectModel/TestRunCriteriaWithSources.cs | Uses STJ [JsonConstructor] under NETCOREAPP. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj | Adds NetCoreApp TFM and removes Newtonsoft.Json package reference. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Messages/VersionedMessage.cs | Deletes VersionedMessage type. |
| src/Microsoft.TestPlatform.CommunicationUtilities/Messages/Message.cs | Updates Message to hold Version/RawMessage and changes ToString semantics. |
| src/Microsoft.TestPlatform.CommunicationUtilities/JsonDataSerializer.Jsonite.cs | Adds Jsonite-based serializer implementation for non-NETCOREAPP. |
| src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionTestCaseEventHandler.cs | Adds logging of received messages (now prints raw JSON via Message.ToString). |
| src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs | Uses message.Version consistently when serializing response payloads. |
| src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs | Uses message.Version consistently when serializing response payloads. |
| playground/AdapterUtilitiesPlayground/AdapterUtilitiesPlayground.csproj | Removes Newtonsoft.Json reference from playground project. |
| eng/verify-nupkgs.ps1 | Adds binding redirect verification and updates expected file counts. |
| eng/build.ps1 | Updates test filtering to include/exclude TestCategory=Performance. |
| eng/Versions.props | Changes version prefix/label (appears to be temporary/incorrect for main). |
| docs/stj-migration-v1-v7-comparison.md | Adds documentation comparing V1 vs V7 wire formats. |
| THIRD-PARTY-NOTICES.txt | Adds Jsonite license notice. |
The merge from main consolidated all test TFMs to net11.0 and net481. Update the hardcoded net8.0 and net462 values to use the standard constants (NET and NETFX). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The merge from main consolidated all test TFMs to net11.0 and net481. Update the hardcoded net8.0 and net462 values to use the standard constants (Core11TargetFramework and Net481TargetFramework). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…l/stj # Conflicts: # test/Microsoft.TestPlatform.Acceptance.IntegrationTests/SerializerSelectionTests.cs
…ramework Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink
approved these changes
Apr 16, 2026
This was referenced Jul 14, 2026
This was referenced Jul 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Originally merged to temporary branch here: #15540 , should go intoVSTest 18.8, VS18.8 and NET11 Preview4.
Summary
Migrate vstest JSON serialization from Newtonsoft.Json to System.Text.Json (on .NET Core) and Jsonite (on .NET Framework/netstandard2.0). Removes Newtonsoft.Json from all production code paths.
Architecture
#if NETCOREAPP#if !NETCOREAPP#if !NETCOREAPPKey Changes
#ifblocks in main filePayloadproperty, usesRawMessagestring + deferred deserializationDependencyContextJsonReaderon .NET Framework (eliminates transitive STJ dep)#if NETcompiler conditions in tests\uXXXXinstead of throwing (testfx#5120)doubleinIDictionary<string, object>(metrics)private set→setonTestCaseId,TestCaseName,IsChildTestCase,TestElement,TestOutcomefor serialization compatibilityTest Coverage
100% MessageType coverage — every single one of the 52 message types in
MessageTypeclass has serialization tests (V1 serialize, V7 serialize, V1 deserialize, V7 deserialize, round-trip).Wire Format Verification
Captured diag logs from blame test runs on both
main(Newtonsoft) andstj-migrationbranches. Parsed and compared all JSON messages from runner, testhost, and datacollector logs:Version,MessageType— ✅ Fast header parser compatiblePerformance: STJ vs Newtonsoft (1000-result batch, V7)
Performance: STJ vs Newtonsoft (single message, 1000 iterations)
Breaking Changes
Message.Payload(JToken?) removed — replaced byMessage.RawMessage(string?) +Message.VersionVersionedMessageclass removed — unified intoMessageTestCaseEventArgs.TestCaseId/TestCaseName/IsChildTestCase/TestElementsetters changed from private/internal to publicTestCaseEndEventArgs.TestOutcomesetter changed from private to publicCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com