Fix serialization of [Experimental] AIContent-derived types#6900
Merged
stephentoub merged 1 commit intodotnet:mainfrom Oct 9, 2025
Merged
Fix serialization of [Experimental] AIContent-derived types#6900stephentoub merged 1 commit intodotnet:mainfrom
stephentoub merged 1 commit intodotnet:mainfrom
Conversation
Member
Author
|
cc: @westey-m |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes serialization issues with experimental AIContent-derived types by implementing a temporary workaround that registers them for JSON serialization without using the JsonDerivedType attributes.
- Adds a comprehensive test to verify serialization roundtrips for all AIContent-derived types
- Implements a temporary workaround to register experimental types for JSON serialization
- Updates error messages and method signatures to support the workaround approach
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| AIContentTests.cs | Adds comprehensive test covering serialization of all AIContent-derived types including experimental ones |
| AIJsonUtilities.cs | Updates method to support bypassing built-in type checks and improves error messages |
| AIJsonUtilities.Defaults.cs | Registers experimental types for serialization and adds them to JsonSerializerContext |
| AIContent.cs | Updates comments explaining the temporary workaround approach |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/AIContentTests.cs
Show resolved
Hide resolved
jozkee
approved these changes
Oct 8, 2025
Member
jozkee
left a comment
There was a problem hiding this comment.
Is there some context of what motivated this change?
Member
Author
Serializing a chat message that contains these types otherwise blows up. |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Defaults.cs
Show resolved
Hide resolved
|
Is it released in nuget. If so which version |
Member
Author
|
It'll be in a new version on nuget later today. |
Member
Author
This was referenced Oct 15, 2025
Merged
This was referenced Nov 13, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Microsoft Reviewers: Open in CodeFlow