-
Notifications
You must be signed in to change notification settings - Fork 3
Fix/recursive-blacklist-check #44
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b63658
fix: Enhance IsTypeBlacklisted method to prevent infinite recursion a…
IvanMurzak 94ec445
fix: Improve blacklist handling by adding caching and invalidation to…
IvanMurzak 7f3f23d
fix: Add tests for blacklisted items in arrays and enhance serializat…
IvanMurzak a314643
fix: Add tests for inheritance with blacklisted generic arguments and…
IvanMurzak ab56aaf
fix: Change blacklisted types and cache dictionaries to readonly for …
IvanMurzak a258dbb
fix: Add max cache size limit for blacklist to prevent memory growth
IvanMurzak 019dd36
fix: Change blacklist cache to a new instance on invalidation to prev…
IvanMurzak e9811d9
fix: Improve blacklist cache invalidation and handling to prevent rac…
IvanMurzak 9b1cba9
fix: Enhance blacklist checks for concurrency and cache invalidation
IvanMurzak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
ReflectorNet.Tests/src/ReflectorTests/BlacklistedArrayItemTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| using Xunit; | ||
| using com.IvanMurzak.ReflectorNet.Model; | ||
| using System.Text.Json; | ||
|
|
||
| namespace com.IvanMurzak.ReflectorNet.ReflectorTests | ||
| { | ||
| public class BlacklistedArrayItemTests | ||
| { | ||
| private class BaseItem { } | ||
| private class AllowedItem : BaseItem { public int Id = 1; } | ||
| private class BlacklistedItem : BaseItem { public int Secret = 999; } | ||
|
IvanMurzak marked this conversation as resolved.
|
||
|
|
||
| [Fact] | ||
| public void TestBlacklistedItemInArray() | ||
| { | ||
| var reflector = new Reflector(); | ||
| reflector.Converters.BlacklistType(typeof(BlacklistedItem)); | ||
|
|
||
| var array = new BaseItem[] | ||
| { | ||
| new AllowedItem(), | ||
| new BlacklistedItem(), | ||
| new AllowedItem() | ||
| }; | ||
|
|
||
| var serialized = reflector.Serialize(array); | ||
| var json = serialized.valueJsonElement?.GetRawText(); | ||
|
|
||
| Assert.NotNull(json); | ||
|
|
||
| // Check if the second element is null | ||
| using (var doc = JsonDocument.Parse(json)) | ||
| { | ||
| var root = doc.RootElement; | ||
| Assert.Equal(JsonValueKind.Array, root.ValueKind); | ||
| Assert.Equal(3, root.GetArrayLength()); | ||
|
|
||
| Assert.NotEqual(JsonValueKind.Null, root[0].ValueKind); | ||
|
|
||
| // This is what we want to verify: | ||
| Assert.Equal(JsonValueKind.Null, root[1].ValueKind); | ||
|
|
||
| Assert.NotEqual(JsonValueKind.Null, root[2].ValueKind); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestSerializedMemberListToStringWithNull() | ||
| { | ||
| var list = new SerializedMemberList(); | ||
| list.Add(null!); | ||
| var str = list.ToString(); | ||
| Assert.Contains("Item[0]", str); | ||
| } | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.