Skip to content

Now serializing empty lists #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025

Conversation

tracyboehrer
Copy link
Member

Fixes #279

@Copilot Copilot AI review requested due to automatic review settings May 13, 2025 19:06
@tracyboehrer tracyboehrer requested a review from a team as a code owner May 13, 2025 19:06
@tracyboehrer tracyboehrer enabled auto-merge May 13, 2025 19:06
@github-actions github-actions bot added ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels May 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #279 by updating the JSON serialization logic to handle empty lists differently based on the SKIP_EMPTY_LISTS compilation symbol. The changes include conditional test assertions for empty arrays, modifications in the serialization converter logic to skip empty collections when required, and updates in model initializers using the new C# 12 array literal syntax.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/Microsoft.Agents.Model.Tests/StreamInfoTests.cs Conditional assertions added to check different JSON outputs based on empty list serialization.
src/tests/Microsoft.Agents.Model.Tests/Resources/cps_typing_out.json Expected JSON updated with empty arrays where applicable.
src/tests/Microsoft.Agents.Model.Tests/Resources/cps_suggestedactions_out.json Expected JSON now includes empty arrays for various properties.
src/tests/Microsoft.Agents.Model.Tests/Resources/cps_greeting_out.json Updated expected JSON with empty arrays for several fields.
src/tests/Microsoft.Agents.Model.Tests/Resources/cps_event_out.json Expected JSON updated to reflect empty arrays in event payloads.
src/tests/Microsoft.Agents.Model.Tests/Resources/ComplexActivityPayload.json Modified the expected value for "listenFor" from an empty array to null.
src/tests/Microsoft.Agents.Model.Tests/ObjectSerializationTests.cs Wrapped tests with conditional compilation to assert serialization output for empty lists.
src/tests/Microsoft.Agents.Model.Tests/ConversationReferenceTests.cs Updated expected JSON in conversation reference tests with empty array properties conditionally.
src/tests/Microsoft.Agents.Model.Tests/ConversationParametersTests.cs Updated expected JSON output to include conditional serialization of empty collections.
src/tests/Microsoft.Agents.Extensions.Teams.Tests/Model/TestJson/MessagingExtensionActionResponse.json Revised expected JSON output to account for empty arrays in nested properties.
src/tests/Microsoft.Agents.Extensions.Teams.Tests/Model/TestJson/MessagingExtensionAction.json Nested activity preview properties now include empty arrays where applicable.
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams/Serialization/Converters/MessagingExtensionAttachmentConverter.cs Added logic to correctly read and write extension data using the new JSON APIs.
src/libraries/Core/Microsoft.Agents.Core/Serialization/Converters/ConnectorConverter.cs Introduced conditional checks to skip empty list properties during serialization and adjusted reading logic.
src/libraries/Core/Microsoft.Agents.Core/Models/VideoCard.cs Updated constructor to initialize collection properties using the new array literal syntax.
src/libraries/Core/Microsoft.Agents.Core/Models/BasicCard.cs Updated initializer to coalesce nulls with new array literal syntax for Images and Buttons.
src/libraries/Core/Microsoft.Agents.Core/Models/Activity.cs Updated constructors to initialize collection properties with empty arrays using the new literal syntax.
Comments suppressed due to low confidence (1)

src/libraries/Core/Microsoft.Agents.Core/Serialization/Converters/ConnectorConverter.cs:69

  • Confirm that skipping serialization of empty lists when SKIP_EMPTY_LISTS is defined does not break external contracts expecting these fields. If empty arrays are required by consumers of the JSON, consider revisiting this logic.
if (propertyValue is IList list)

@tracyboehrer tracyboehrer merged commit 05bde98 into main May 13, 2025
8 of 9 checks passed
@tracyboehrer tracyboehrer deleted the users/tracyboehrer/activity-init-collections branch May 13, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ML: Core Tags changes to core libraries ML: Tests Tags changes to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't skip empty lists during serialization
2 participants