Refactor the state of search expressions as OneOrMany.#511
Merged
Conversation
There was a problem hiding this comment.
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>.AddSortedand 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()
This was referenced Aug 20, 2025
Closed
Closed
Closed
Closed
Closed
This was referenced Jan 9, 2026
This was referenced Jan 18, 2026
Open
This was referenced Jan 30, 2026
This was referenced Feb 9, 2026
Open
Open
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.
It addresses the issue #506