Migrates the AdaptiveCards .NET library from Newtonsoft.Json to System.Text.Json - #9357
Migrates the AdaptiveCards .NET library from Newtonsoft.Json to System.Text.Json#9357Phil Nachreiner (philnach) wants to merge 20 commits into
Conversation
…or Newtonsoft.Json to System.Text.Json migration
…d fix JsonNode.Merge
…cument known issues
|
Phil Nachreiner (@philnach) looking forward to this! |
|
Copilot , can you take a stab at reviewing this code. Look for any areas where the switch to System.Text.Json doesn't meet the AdaptiveCards spec. Suggest possible improvements or simplifications. Pay attention to new code being added and if adequate new testing is present. |
|
Phil Nachreiner (@philnach) I've opened a new pull request, #9358, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
Copilot, great you opened a new PR, but not how do I get that PR into this PR so they go in together? |
|
Phil Nachreiner (@philnach) I've opened a new pull request, #9359, to work on those changes. Once the pull request is ready, I'll request review from you. |
… and regression tests - AdaptiveFallbackConverter.IsInFallback: [ThreadStatic] to prevent cross-thread corruption - AdaptiveCollectionElementConverter.Write: respect per-property JsonIgnore conditions - AdaptiveElement.IsVisible: remove WhenWritingDefault to preserve false values - SafeJsonHelper: fix unresolvable cref XML doc warning - Test TFM: net6.0 -> net8.0 - 3 new regression tests: concurrent fallback, default-value suppression, IsVisible roundtrip - Updated migration docs with bug fix details
|
I closed Copilots 2 review attempts and merged the changes into this PR. This PR is complete and ready for review. Please see PR description for all changes, the plan that went into the changes. Testing, etc. |
Related Issue
Fixes #9146
Description
Migrates the AdaptiveCards .NET library from Newtonsoft.Json to System.Text.Json, modernizing the serialization stack while maintaining backward compatibility and removing the transitive dependency on Newtonsoft.Json.
Core Migration
[JsonProperty],[JsonConverter], and other Newtonsoft.Json attributes with System.Text.Json equivalents across all model classesSystem.Text.JsonJsonConverter<T>APIAdaptiveActionPolymorphicConverter,AdaptiveCollectionElementConverterFactory,AdaptiveCardSerializationContextfor polymorphic type handlingSafeJsonHelper(duplicate-key-safeJsonObjectconstruction) andWarningContextBug Fixes (post-review)
AdaptiveFallbackConverter.IsInFallbackwas a shared static; concurrent parses could corrupt the fallback flag. Fixed with[ThreadStatic].AdaptiveCollectionElementConverter.Writeignored per-propertyWhenWritingNull/WhenWritingDefaultconditions, emitting noise like"separator": false,"bleed": false. Fixed by reading each property'sJsonIgnoreAttribute.Condition.IsVisible = falseroundtrip regression:[JsonIgnore(Condition = WhenWritingDefault)]on aboolskipsfalse(the type default), causing hidden elements to reappear. Removed the condition;isVisibleis now always serialized.WPF Renderer & Visualizer
double?change onAdaptiveNumberInputand fixedJsonNode.MergeInternalIDnull safety, indexer skip, and documented known issuesMessageBoxwith selectable/copyableTextBoxin both VisualizersUseShellExecuteforProcess.Starton .NET 6XceedNumberInput.csfordouble?null safetyNuGet Feed
source/dotnet/NuGet.configto publicshine-ossfeed for external contributor accessNuGet.configforImageRendererServer(requires internalMicrosoft.Internal.AntiSSRF)Testing
SystemTextJsonMigrationTests(160+ tests) covering round-trip, polymorphic dispatch, edge casesConcurrentFallbackParsing_IsThreadSafe,CollectionElements_DefaultPropertiesAreNotSerialized,IsVisible_False_RoundtripsCorrectlyDocumentation
system-text-json-migration-guide.mdfor library consumerssystem-text-json-migration-plan.mdwith migration strategy and bug fix detailsImpact
"isVisible": truenow always appears in serialized outputSample Card
No new sample card needed. Existing
samples/cards exercise all affected element types.How Verified
SystemTextJsonMigrationTestswith 160+ tests covering round-trip serialization, thread safety, default-value suppression, andIsVisibleroundtrip.DirectoryNotFoundExceptionfailures unrelated).Input.Numberwith min/max/value and null variants tested.