Skip to content

Adding support for any collection in ExpressionEqualityComparer #37212#37250

Merged
roji merged 1 commit intodotnet:mainfrom
kirolous-nashaat:main
Feb 13, 2026
Merged

Adding support for any collection in ExpressionEqualityComparer #37212#37250
roji merged 1 commit intodotnet:mainfrom
kirolous-nashaat:main

Conversation

@kirolous-nashaat
Copy link
Contributor

@kirolous-nashaat kirolous-nashaat commented Nov 27, 2025

Extend GetHashCode to handle IEnumerable objects, ensuring proper hash code generation for collections.

Add support for comparing IEnumerable objects using SequenceEqual, enhancing robustness for constant value comparisons.

Closes #37212

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
  • Tests for the changes have been added (for bug fixes / features)
    Existing test already cover this, removed the old workaround for ignore query filters
  • Code follows the same patterns and style as existing code in this repo

@roji
Copy link
Member

roji commented Feb 12, 2026

@kirolous-nashaat thanks for submitting and sorry it took so long to review.

The PR looks good, but enumerating in this way over any IEnumerable could potentially be problematic; IEnumerables aren't necessarily materialized collections, and enumerating them can be arbitrarily expensive. I've opened #37684 to look into materializing IEnumerables early, at which point your PR would be totally fine. I'll take a look at that first.

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked at this, and #37684 presents some difficulties. It's also not really necessary to do it before this - the current behavior of having query cache misses - and the resulting constant query recompilation - is likely to be far worse than the enumeration here.

Note that parameterized lists/collections/enumerables isn't a problem, as these get extracted out beforehand by the funcletizer. So this likely affects a very small minority of scenarios in any case.

So I'm pushing a few style tweaks and will merge, thanks for your contribution!

@roji roji enabled auto-merge (squash) February 13, 2026 10:52
@roji roji disabled auto-merge February 13, 2026 20:01
@roji roji merged commit ee7109f into dotnet:main Feb 13, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding support for any collection/enumerable in ExpressionEqualityComparer

3 participants