Repository navigation
Fix trait serialization under NativeAOT - #16636
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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.Jsonfor trait parsing on .NET Core targets while retainingDataContractJsonSerializeron 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
Jakub Jareš (nohwnd)
approved these changes
Nov 5, 2026
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.
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