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 12:00
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

Consolidates the OneOrMany<T> API by exposing a List property and updating all existing consumers to use it, and adds tests for the new List accessor.

  • Added List and SingleOrDefault properties with XML documentation to OneOrMany<T>.
  • Refactored SearchValidator, SearchMemoryEvaluator, and EF SearchEvaluator to call the new List property instead of type-checking Values.
  • Introduced unit tests for the List accessor in OneOrManyTests.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Ardalis.Specification.Tests/Internals/OneOrManyTests.cs Added tests for the new List property
src/Ardalis.Specification/Internals/OneOrMany.cs Implemented List and SingleOrDefault accessors
src/Ardalis.Specification/Validators/SearchValidator.cs Switched from checking Values to using List directly
src/Ardalis.Specification/Evaluators/SearchMemoryEvaluator.cs Updated to use List accessor for search expressions
src/Ardalis.Specification.EntityFrameworkCore/Evaluators/SearchEvaluator.cs Updated EF evaluator to span over the new List property
Comments suppressed due to low confidence (2)

tests/Ardalis.Specification.Tests/Internals/OneOrManyTests.cs:214

  • Tests cover the List accessor but do not verify the new SingleOrDefault property behavior. Add tests for SingleOrDefault in the empty, single, and multiple item scenarios.
}

src/Ardalis.Specification/Internals/OneOrMany.cs:75

  • [nitpick] Exposing the mutable List<T> allows external callers to modify internal state. Consider returning IReadOnlyList<T> or a defensive copy to preserve encapsulation.
public readonly List<T> List

@fiseni fiseni merged commit 0309d7c into main Jun 13, 2025
1 check passed
@fiseni fiseni deleted the fiseni/oneormany-consolidation 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