Fix serialization priority and improve deserialization in ArrayReflectionConvertor#30
Conversation
…c and add ParseElementToMember method
Test Results 3 files 3 suites 3m 5s ⏱️ Results for commit 908b5e4. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
This PR refactors array deserialization logic in the ArrayReflectionConvertor to work directly with JSON arrays instead of deserializing through SerializedMemberList, and adjusts the serialization priority to properly exclude strings from array handling.
Key Changes:
- Strings now explicitly return priority 0 before the general IEnumerable check, preventing them from being treated as arrays
- Array deserialization refactored to parse JsonElement arrays directly rather than first deserializing to SerializedMemberList
- New
ParseElementToMembermethod intelligently handles both structured SerializedMember objects and simple JSON values
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| ReflectorNet/src/Convertor/Reflection/ArrayReflectionConvertor.cs | Fixed serialization priority for strings by explicitly checking for typeof(string) before the IEnumerable check, preventing strings from being treated as collection types |
| ReflectorNet/src/Convertor/Reflection/ArrayReflectionConvertor.Deserialize.cs | Refactored deserialization to work directly with JSON arrays, removed System.Linq dependency, and added ParseElementToMember method to handle both structured and simple array elements |
Comments suppressed due to low confidence (1)
ReflectorNet/src/Convertor/Reflection/ArrayReflectionConvertor.Deserialize.cs:167
- This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
foreach (var element in jsonArray.EnumerateArray())
{
var member = ParseElementToMember(element);
var deserializedElement = reflector.Deserialize(
member,
fallbackType: elementType,
depth: depth + 1,
stringBuilder: stringBuilder,
logger: logger);
addMethod.Invoke(list, new[] { deserializedElement });
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nvertor with ParseElementToMember method
…th SerializedMember.ValueName
…ing deserialization
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
ReflectorNet/src/Convertor/Reflection/ArrayReflectionConvertor.Deserialize.cs:167
- This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
foreach (var element in jsonArray.EnumerateArray())
{
var member = ParseElementToMember(element);
var deserializedElement = reflector.Deserialize(
member,
fallbackType: elementType,
depth: depth + 1,
stringBuilder: stringBuilder,
logger: logger);
addMethod.Invoke(list, new[] { deserializedElement });
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adjust serialization priority for string types and enhance the array deserialization logic by adding a new method for parsing elements to members.