-
Notifications
You must be signed in to change notification settings - Fork 253
Refactor the state of search expressions as OneOrMany. #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the internal List<SearchExpressionInfo<T>>?
with the new OneOrMany<SearchExpressionInfo<T>>
abstraction across the specification, evaluator, and validator layers, and adds tests to cover single and null-property search cases.
- Introduced
OneOrMany<SearchExpressionInfo<T>>
inSpecification<T>
and wired it through validators and evaluators. - Updated sorted insertion logic in
OneOrMany<T>.AddSorted
and addedSearchExpressionComparer<T>
. - Added unit tests for single-search scenarios, including handling of null properties.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/.../SearchValidatorTests.cs | New test for null-property search in SearchValidator |
tests/.../SearchMemoryEvaluatorTests.cs | New test for single-search filtering in SearchMemoryEvaluator |
src/Ardalis.Specification/Validators/SearchValidator.cs | Switched to OneOrManySearchExpressions and added single-case branch |
src/Ardalis.Specification/Specification.cs | Replaced nullable List<SearchExpressionInfo<T>> with OneOrMany<SearchExpressionInfo<T>> |
src/Ardalis.Specification/Internals/OneOrMany.cs | Tweaked comparison in AddSorted (changed <= to < ) |
src/Ardalis.Specification/Expressions/SearchExpressionInfo.cs | Added SearchExpressionComparer<T> for sorted insertion |
src/Ardalis.Specification/Evaluators/SearchMemoryEvaluator.cs | Added SpecSingleLikeIterator and used OneOrManySearchExpressions |
src/Ardalis.Specification.EntityFrameworkCore/Evaluators/SearchEvaluator.cs | Updated to use OneOrManySearchExpressions in EF evaluator |
Comments suppressed due to low confidence (1)
tests/Ardalis.Specification.Tests/Validators/SearchValidatorTests.cs:66
- [nitpick] The test method name contains a double underscore before 'WithNullProperty'. Consider using a single underscore for consistency and readability.
public void ReturnsFalse_GivenSpecWithSingleSearch__WithNullProperty()
It addresses the issue #506