-
Notifications
You must be signed in to change notification settings - Fork 839
Fix serialization of [Experimental] AIContent-derived types #6900
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
Conversation
cc: @westey-m |
There was a problem hiding this 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 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some context of what motivated this change?
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 |
It'll be in a new version on nuget later today. |
Microsoft Reviewers: Open in CodeFlow