Skip to content

Conversation

ArthurFreeb
Copy link

This pull request refactors property path evaluation logic in FilterEvaluator.cs to improve null safety and correctness when navigating nested properties in query expressions. The main changes involve introducing guarded property path evaluation, handling null comparisons more robustly, and updating related methods to use the new approach.

Property Path Evaluation & Null Safety

  • Added BuildPropertyPathWithGuard to safely build property paths with guard expressions, ensuring null checks are applied when navigating nested properties. All relevant evaluation methods now use this function instead of the previous BuildPropertyPath.
  • Updated property path evaluation in EvaluatePropertyPathExpression and lambda property path handling to use guard expressions and combine them with value comparisons, improving null handling for complex queries. [1] [2]

Null Comparison Logic

  • Introduced ComposeNestedNullComparison to handle equality and inequality operations with null values on nested properties, using guard expressions to prevent null reference errors.
  • Added RequiresFinalNotNull helper to determine when additional null checks are needed for the final property in a path, ensuring correct logical behavior in comparisons.

Code Consistency & Minor Cleanups

  • Updated several methods to remove redundant comments and improve code clarity, especially around property navigation and collection element type resolution. [1] [2] [3] [4] [5] [6] [7] [8]
  • Fixed return type in ResolveCollectionProperty to ensure proper casting to MemberExpression.

@ArthurFreeb
Copy link
Author

This refactor introduces a guarded path builder and composes eq/ne null semantics so nested navigation can’t throw. A couple of cleanups I could do next:
• Consolidate the two path builders (phase out the unguarded BuildPropertyPath to avoid divergent code paths).
• In ComposeNestedNullComparison, fail explicitly for operators other than eq/ne when RHS is null, instead of returning a default expression.
• Remove the unused container return value from BuildPropertyPathWithGuard (or use it if we need it later).
• Add tests for deep nested nulls and the same cases inside any/all lambdas to lock in the behavior.

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.

1 participant