Fix/recusrive-serialization-loop#43
Merged
IvanMurzak merged 3 commits intomainfrom Jan 4, 2026
Merged
Conversation
…aces, arrays, and generics
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a recursive serialization loop issue by implementing circular reference handling in the JSON serializer and enhancing the type blacklist checking mechanism to comprehensively detect blacklisted types in inheritance hierarchies, interfaces, arrays, and generics.
- Enabled
ReferenceHandler.IgnoreCyclesin JsonSerializer to prevent stack overflow from circular object references - Enhanced
IsTypeBlacklistedto check inheritance chains, implemented interfaces, array element types, and generic type arguments recursively - Added comprehensive test coverage with 35 test cases covering various blacklist scenarios including edge cases
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ReflectorNet/src/Utils/Json/JsonSerializer.cs | Enabled ReferenceHandler.IgnoreCycles to prevent stack overflow from circular references during JSON serialization |
| ReflectorNet/src/Reflector/Reflector.Registry.cs | Enhanced IsTypeBlacklisted method to recursively check base types, interfaces, array elements, and generic type arguments for blacklisted types |
| ReflectorNet.Tests/src/ReflectorTests/IsTypeBlacklistedTests.cs | Added comprehensive test suite with 35 test cases covering null handling, exact matches, inheritance chains, interfaces, arrays, generics, nested combinations, nullable types, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request enhances type blacklisting logic and improves JSON serialization handling for circular references. The most important changes are grouped below.
Type Blacklisting Improvements
IsTypeBlacklistedinReflector.Registry.csto check not only the exact type but also base types, implemented interfaces, arrays of blacklisted types, and generic types containing blacklisted type arguments. This makes blacklisting much more thorough and robust.JSON Serialization Improvements
JsonSerializerinJsonSerializer.csto useReferenceHandler.IgnoreCyclesinstead of the previous commented-outReferenceHandler.Preserve. This prevents stack overflow errors caused by circular references during serialization.