Skip to content

Add structural equality for UriParser SemanticAst clauses and nodes#3542

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-equality-overrides-for-clauses
Draft

Add structural equality for UriParser SemanticAst clauses and nodes#3542
Copilot wants to merge 2 commits into
mainfrom
copilot/add-equality-overrides-for-clauses

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown

Parsed OData query options do not currently support structural equality, which makes semantic comparison of $filter, $orderby, $search, and $select/$expand trees difficult for caching and tests. This change adds draft equality support across the core SemanticAst surface used by those parsed query options.

  • Public equality surface

    • Added IEquatable<T>, Equals, and GetHashCode to:
      • QueryNode
      • RangeVariable
      • FilterClause
      • OrderByClause
      • SearchClause
      • SelectExpandClause
  • Structural comparison implementation

    • Introduced an internal SemanticAstStructuralEqualityComparer to compare bound query trees by structure rather than object identity.
    • Covers:
      • nested QueryNode graphs
      • RangeVariable state
      • SelectItem / expand item trees
      • ODataPath instances
      • nested clause state such as ComputeClause, LevelsClause, and ApplyClause
  • Select/expand support

    • Equality for SelectExpandClause now walks selected items and nested options instead of relying on reference equality.
    • This includes expanded navigation/reference/count items and nested clause options carried on them.
  • API baseline

    • Recorded the new public members in the PublicAPI.Unshipped.txt baselines for supported target frameworks.
  • Regression coverage

    • Added parser-based tests that compare separately parsed but semantically equivalent trees for:
      • $filter
      • $orderby
      • $search
      • $select/$expand
    • Also added non-equivalence cases to verify the comparer distinguishes different semantics.

Example:

var left = new ODataQueryOptionParser(model, type, set,
    new Dictionary<string, string> { ["$filter"] = "MyDog/Color eq 'Brown'" })
    .ParseFilter();

var right = new ODataQueryOptionParser(model, type, set,
    new Dictionary<string, string> { ["$filter"] = "MyDog/Color eq 'Brown'" })
    .ParseFilter();

bool equal = left.Equals(right); // true

Copilot AI changed the title [WIP] Add equality overrides for Filter, SelectAndExpand, Search, and other clauses Add structural equality for UriParser SemanticAst clauses and nodes May 26, 2026
Copilot finished work on behalf of xuzhg May 26, 2026 21:04
Copilot AI requested a review from xuzhg May 26, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Equality overrides for Filter|SelectAndExpand|Search|other-Clauses

2 participants