| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR adjusts .NET ChatClientAgentSession JSON deserialization behavior to work with stricter System.Text.Json settings (notably RespectRequiredConstructorParametersDefault=true) when optional properties are omitted due to JsonIgnoreCondition.WhenWritingNull.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentSession.cs | Updates the [JsonConstructor] signature to accept omitted JSON properties via optional parameters and documents the constructor. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentSessionTests.cs | Adds a test covering WhenWritingNull serialization + subsequent deserialization using provided options. |
Sorry, something went wrong.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
VerifyDeserializeWithWhenWritingNullOptions passed against both the old and the fixed constructor, so it did not guard against the regression. The bug only reproduces when required constructor parameters are respected (the issue uses RespectRequiredConstructorParametersDefault=true). With WhenWritingNull a null conversationId is omitted from the JSON, and STJ then throws 'missing required properties including: conversationId' because the constructor parameter had no default value. Adding RespectRequiredConstructorParameters = true to the test options makes the test red against the parameter-without-default constructor and green with the default-valued constructor parameters, so it now protects the fix.
| Back | FazBrowse Home | New Git URL |
fix #7109