Skip to content

Fix trait serialization under NativeAOT - #16636

Merged
Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
peterwald:pw-aot-support
Nov 5, 2026
Merged

Jakub Jareš (nohwnd) merged 1 commit into
microsoft:mainfrom
peterwald:pw-aot-support

Conversation

@peterwald

Copy link
Copy Markdown
Member

Description

CustomKeyValueConverter still uses DataContractJsonSerializer to serialize TraitObject. This update makes serialization compatible with loading the ObjectModel assembly in a NativeAOT process.

Related issue

Required to fix microsoft/vscode-dotnettools#3723

  • I have ensured that there is a previously discussed and approved issue.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The NativeAOT trait deserialization change has no active review issues.

No open issues 🎉

What changed in this PR

This PR makes ObjectModel trait deserialization compatible with NativeAOT consumers of the VSTest TranslationLayer.

Changes:

  • Uses System.Text.Json for trait parsing on .NET Core targets while retaining DataContractJsonSerializer on other targets.
  • Adds unit coverage for escaped, nullable, missing, and reordered trait members.
  • Extends NativeAOT runtime checks to verify discovery payloads preserve duplicate traits, order, and escaped values across protocol versions 2 and 7.
File Description
test/​TestAssets/​NativeAotTranslationLayerConsumer/​Program.cs Validates traits in discovery messages under NativeAOT.
test/​Microsoft.TestPlatform.ObjectModel.UnitTests/​CustomKeyValueConverterTests.cs Adds trait parsing edge-case tests.
test/​Microsoft.TestPlatform.CommunicationUtilities.UnitTests/​NativeAotCompatibilityTests.cs Requires the discovery-trait runtime success marker.
src/​Microsoft.TestPlatform.ObjectModel/​TestProperty/​CustomKeyValueConverter.cs Replaces reflection-based trait parsing on .NET Core targets.

Review effort: Balanced

@nohwnd
Jakub Jareš (nohwnd) merged commit 4b86a08 into microsoft:main Nov 5, 2026
21 checks passed
@peterwald
Peter Waldschmidt (peterwald) deleted the pw-aot-support branch November 5, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# Dev Kit reports discovery aborted after VSTest successfully discovers 423 tests

3 participants