Skip to content

Fix/recusrive-serialization-loop#43

Merged
IvanMurzak merged 3 commits intomainfrom
fix/recusrive-serialization-loop
Jan 4, 2026
Merged

Fix/recusrive-serialization-loop#43
IvanMurzak merged 3 commits intomainfrom
fix/recusrive-serialization-loop

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

@IvanMurzak IvanMurzak commented Jan 4, 2026

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

  • Expanded the logic in IsTypeBlacklisted in Reflector.Registry.cs to 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

  • Changed the JsonSerializer in JsonSerializer.cs to use ReferenceHandler.IgnoreCycles instead of the previous commented-out ReferenceHandler.Preserve. This prevents stack overflow errors caused by circular references during serialization.

@IvanMurzak IvanMurzak self-assigned this Jan 4, 2026
@IvanMurzak IvanMurzak requested a review from Copilot January 4, 2026 12:58
@IvanMurzak IvanMurzak added bug Something isn't working enhancement New feature or request labels Jan 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 4, 2026

Test Results

    3 files  ±  0      3 suites  ±0   6m 12s ⏱️ -45s
  964 tests + 44    964 ✅ + 44  0 💤 ±0  0 ❌ ±0 
2 854 runs  +132  2 854 ✅ +132  0 💤 ±0  0 ❌ ±0 

Results for commit 9e0fa91. ± Comparison against base commit 137d400.

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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.IgnoreCycles in JsonSerializer to prevent stack overflow from circular object references
  • Enhanced IsTypeBlacklisted to 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.

Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
@IvanMurzak IvanMurzak merged commit 194b304 into main Jan 4, 2026
1 check passed
@IvanMurzak IvanMurzak deleted the fix/recusrive-serialization-loop branch January 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants