Key the combinations name cache by reference - #1861
Merged
Merged
Conversation
The cache was a Dictionary<object, string> using the boxed value's own equality, so keys that compare equal but render differently shared one name: DateTime.Equals ignores Kind and DateTimeOffset.Equals compares only the instant, while both of those are part of the rendered name. A combination over 2000-01-01 Utc, Local and Unspecified labeled every row 2000-01-01Utc. Each input list is materialized once, so a key recurs as the same boxed instance and reference equality is what the cache actually wants.
This was referenced Aug 26, 2026
This was referenced Aug 27, 2026
Open
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.
CombinationResultsConvertercaches the rendered name per key in aDictionary<object, string>, which used the boxed value's own equality. Two keys that compare equal but render differently therefore shared one name:DateTime.EqualsignoresKind, but the name carries it.DateTimeOffset.Equalscompares only the instant, but the name carries the offset.A combination over
2000-01-01as Utc, Local and Unspecified labeled all three rows2000-01-01Utc— so the output had duplicate property names and no way to tell the rows apart. Same for2000-01-01T00:00+00:00against2000-01-01T01:00+01:00.Each input list is materialized once (
a.Cast<object?>()thenToArray()in theCombinationRunnerconstructor) and rows index into that array, so a key recurs as the same boxed instance. Reference equality is what the cache actually wants, and it sidesteps the value equality traps entirely — that is now what it uses, via a small internalReferenceComparer.Worth noting
Counteralready treats these as distinct (DateTimeComparercomparesKind, and there is aDateTimeOffsetequivalent), so this brings the converter in line with the rest of the codebase.Test
CombinationTests.DateKeysThatCompareEqualcombines the threeDateTimeKindvalues against two equal-instant offsets. Onmainall six rows come out labeled2000-01-01Utc, 2000-01-01+0; with the fix each row is distinct.Verify.Tests(1300) andStaticSettingsTestspass, andVerifybuilds for all nine target frameworks.