Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Jun 13, 2025

It addresses the issue #506

@fiseni fiseni requested a review from Copilot June 13, 2025 10:04
Copy link

@Copilot Copilot AI left a 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>> in Specification<T> and wired it through validators and evaluators.
  • Updated sorted insertion logic in OneOrMany<T>.AddSorted and added SearchExpressionComparer<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()

@fiseni fiseni merged commit aa4dd63 into main Jun 13, 2025
1 check passed
@fiseni fiseni deleted the fiseni/oneormany-search branch June 13, 2025 12:09
@fiseni fiseni linked an issue Jun 13, 2025 that may be closed by this pull request
This was referenced Aug 20, 2025
This was referenced Aug 25, 2025
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.

Use OneOrMany for all internal collections
1 participant