Skip to content

Fix/recursive-blacklist-check#44

Merged
IvanMurzak merged 9 commits intomainfrom
fix/recursive-blacklist-check
Jan 4, 2026
Merged

Fix/recursive-blacklist-check#44
IvanMurzak merged 9 commits intomainfrom
fix/recursive-blacklist-check

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

@IvanMurzak IvanMurzak commented Jan 4, 2026

This pull request enhances the blacklisting functionality in the ReflectorNet library, focusing on more robust and efficient detection of blacklisted types—including those involved in generics, inheritance, and interface implementations. It introduces a caching mechanism for blacklist checks, improves array serialization behavior for blacklisted elements, and adds comprehensive tests for these scenarios.

Blacklisting logic and performance improvements:

  • Added a cache (_blacklistCache) to the Registry class to speed up repeated blacklist checks and ensure cache is cleared whenever the blacklist is updated. Blacklist checks now use a recursive, cycle-safe method that covers inheritance, interfaces, arrays, and generics. [1] [2] [3] [4] [5]

Array serialization behavior:

  • Updated ArrayReflectionConverter to serialize blacklisted array elements as null, ensuring that arrays containing blacklisted types are handled gracefully during serialization.

Test coverage enhancements:

  • Added new tests in BlacklistedArrayItemTests to verify that arrays with blacklisted items serialize those elements as null and that SerializedMemberList stringifies lists with nulls correctly.
  • Expanded IsTypeBlacklistedTests to cover scenarios involving generic interfaces with blacklisted type arguments, inheritance from generics with blacklisted arguments, and deep inheritance chains, ensuring all edge cases are detected. [1] [2] [3]

@IvanMurzak IvanMurzak self-assigned this Jan 4, 2026
@IvanMurzak IvanMurzak requested a review from Copilot January 4, 2026 21:35
@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   7m 17s ⏱️ + 7m 15s
  975 tests +  816    975 ✅ +  816  0 💤 ±0  0 ❌ ±0 
2 887 runs  +2 707  2 887 ✅ +2 707  0 💤 ±0  0 ❌ ±0 

Results for commit 9b1cba9. ± Comparison against base commit b3a5365.

♻️ This comment has been updated with latest results.

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 improves the type blacklist checking mechanism in ReflectorNet by adding recursive checks for generic type arguments and implementing a caching layer for performance optimization.

Key Changes:

  • Adds caching mechanism to avoid redundant blacklist checks for the same types
  • Implements recursive checking for generic type arguments in interfaces and base classes
  • Adds protection against infinite recursion using a visited set
  • Optimizes array element serialization to skip blacklisted items

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
ReflectorNet/src/Reflector/Reflector.Registry.cs Implements caching and recursive blacklist checking logic with cycle detection
ReflectorNet/src/Converter/Reflection/ArrayReflectionConverter.cs Adds runtime type checking to serialize blacklisted array elements as null
ReflectorNet.Tests/src/ReflectorTests/IsTypeBlacklistedTests.cs Adds comprehensive tests for generic interfaces with blacklisted type arguments and inheritance scenarios
ReflectorNet.Tests/src/ReflectorTests/BlacklistedArrayItemTests.cs Adds tests verifying blacklisted array elements are properly handled as null values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs Outdated
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs
Comment thread ReflectorNet/src/Reflector/Reflector.Registry.cs
Comment thread ReflectorNet.Tests/src/ReflectorTests/BlacklistedArrayItemTests.cs
Comment thread ReflectorNet.Tests/src/ReflectorTests/BlacklistedArrayItemTests.cs
@IvanMurzak IvanMurzak merged commit b52932c into main Jan 4, 2026
2 checks passed
@IvanMurzak IvanMurzak deleted the fix/recursive-blacklist-check branch January 4, 2026 23:35
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