-
Notifications
You must be signed in to change notification settings - Fork 51
Update ConnectorConverter to honer JsonIgnore and JsonPropertyName #305
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
Update ConnectorConverter to honer JsonIgnore and JsonPropertyName #305
Conversation
ee16fee
to
4eb259a
Compare
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 updates the ConnectorConverter
to respect [JsonIgnore]
and [JsonPropertyName]
attributes, adds reflection-based caching to improve performance, and removes manual property handling in the AIEntityConverter
. Corresponding tests have been added to verify derived-entity support, concurrency safety, and duplicate property-name errors.
- Introduce
GetCachedProperties
andGetPropertyMap
with caching inConnectorConverter
- Honor
JsonIgnoreAttribute
andJsonPropertyNameAttribute
when writing JSON - Remove handwritten type/context/id mapping in
AIEntityConverter
and enable attribute-based mapping - Add tests for derived entities, list serialization, concurrency, and duplicate JSON property detection
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/tests/Microsoft.Agents.Model.Tests/ObjectSerializationTests.cs | Added tests for derived-entity serialization, list-of-activities, concurrency, and duplicate-name errors |
src/libraries/Core/Microsoft.Agents.Core/Serialization/Converters/ConnectorConverter.cs | Added property-reflection caching, name-resolution cache, and attribute handling |
src/libraries/Core/Microsoft.Agents.Core/Serialization/Converters/AIEntityConverter.cs | Removed manual @type /@context /@id branches in favor of attribute-based mapping |
src/libraries/Core/Microsoft.Agents.Core/Models/AIEntity.cs | Uncommented [JsonPropertyName] on AtType , AtContext , and AtId |
Comments suppressed due to low confidence (1)
src/tests/Microsoft.Agents.Model.Tests/ObjectSerializationTests.cs:382
- [nitpick] The
[ ... ]
collection expression may not be recognized in all C# versions or contexts. For clarity and compatibility, consider usingnew List<Activity> { new DerivedActivity { ... } }
.
List<Activity> activities = [new DerivedActivity
Fixes #298
Added GetCachedProperties: Caches PropertyInfo[] per type to avoid repeated reflection.
Added GetPropertyMap: Resolves JSON property names considering:
Added support for JsonIgnoreAttribute during serialization to skip ignored properties
Use JsonPropertyNameAttribute to ensure property names are correctly mapped during read/write
Remove manual property name handling in AIEntityConverter