Skip to content

Keep empty collections ignored alongside instance predicates - #1860

Merged
SimonCropp merged 2 commits into
mainfrom
fix-ignoreinstance-empty-collections
Aug 17, 2026
Merged

Keep empty collections ignored alongside instance predicates#1860
SimonCropp merged 2 commits into
mainfrom
fix-ignoreinstance-empty-collections

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Aug 17, 2026

Copy link
Copy Markdown
Member

TryGetScrubOrIgnoreByInstance returned as soon as it found predicates registered for the value's runtime type and none of them matched, which skipped the ignoreEmptyCollections check sitting below it.

So registering any IgnoreInstance<List<string>> or ScrubInstance<List<string>> predicate — even one that never matches, and regardless of what it was for — quietly turned off empty-collection handling for List<string>, and empty ones started appearing as [].

No predicate matching is not a decision to keep the value, so the empty collection check now runs whether or not predicates were registered for the type.

IgnoreInstanceTests.NonMatchingPredicateKeepsEmptyCollectionsIgnored registers a never-matching predicate and verifies an empty and a non-empty collection of that type. It fails on main, where the empty one renders as [].

The test is in its own file rather than appended to SerializationTests, so it does not collide with #1859, which appends there. Verified: the two branches now merge clean, and the merged result passes (1301).

Verify.Tests (1300) and StaticSettingsTests pass.

@SimonCropp SimonCropp added this to the 32.0.0 milestone Aug 17, 2026
TryGetScrubOrIgnoreByInstance returned as soon as it found predicates registered
for the value's type and none of them matched, skipping the empty collection
check below it. So an empty List<string> started rendering as [] merely because
some unrelated IgnoreInstance or ScrubInstance predicate had been registered for
that type.

No predicate matching is not a decision to keep the value, so the empty
collection check now runs either way.

The test lives in its own file rather than being appended to SerializationTests,
so this does not collide with the other pending fixes that append there.
@SimonCropp
SimonCropp force-pushed the fix-ignoreinstance-empty-collections branch from fed73d9 to 80fb845 Compare August 17, 2026 12:34
@SimonCropp
SimonCropp merged commit 2fbb653 into main Aug 17, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the fix-ignoreinstance-empty-collections branch August 17, 2026 22:24
This was referenced Aug 26, 2026
This was referenced Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant