Skip to content

Consolidate OneOrMany implementation and its usage.#513

Merged
fiseni merged 1 commit into
mainfrom
fiseni/oneormany-consolidation
Jun 13, 2025
Merged

Consolidate OneOrMany implementation and its usage.#513
fiseni merged 1 commit into
mainfrom
fiseni/oneormany-consolidation

Conversation

@fiseni

@fiseni fiseni commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator

It addresses the issue #506

@fiseni fiseni requested a review from Copilot June 13, 2025 12:00

Copilot AI left a comment

Copy link
Copy Markdown

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

Comment thread src/Ardalis.Specification/Validators/SearchValidator.cs
Comment thread src/Ardalis.Specification/Evaluators/SearchMemoryEvaluator.cs
@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
gritcsenko added a commit to gritcsenko/HomeInventory that referenced this pull request Aug 24, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
|
[Ardalis.Specification](https://redirect.github.com/ardalis/specification)
| `9.2.0` -> `9.3.0` |
[![age](https://developer.mend.io/api/mc/badges/age/nuget/Ardalis.Specification/9.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Ardalis.Specification/9.2.0/9.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>ardalis/specification (Ardalis.Specification)</summary>

###
[`v9.3.0`](https://redirect.github.com/ardalis/Specification/releases/tag/v9.3.0)

#### What's Changed

- Avoid List allocation for PostProcessingAction. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#501](https://redirect.github.com/ardalis/Specification/pull/501)
- Redefine WithProjectionOf as an extension to Specification instead of
ISpecification by [@&#8203;fiseni](https://redirect.github.com/fiseni)
in
[ardalis/Specification#517](https://redirect.github.com/ardalis/Specification/pull/517)
- Rename TagWithEvaluator to QueryTagEvaluator. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#512](https://redirect.github.com/ardalis/Specification/pull/512)
- OneOrMany implementation by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#507](https://redirect.github.com/ardalis/Specification/pull/507)
- Refactor the state of where expressions as OneOrMany. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#508](https://redirect.github.com/ardalis/Specification/pull/508)
- Refactor the state of order expressions as OneOrMany. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#509](https://redirect.github.com/ardalis/Specification/pull/509)
- Refactor the state of include expressions as OneOrMany. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#510](https://redirect.github.com/ardalis/Specification/pull/510)
- Refactor the state of search expressions as OneOrMany. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#511](https://redirect.github.com/ardalis/Specification/pull/511)
- Consolidate OneOrMany implementation and its usage. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#513](https://redirect.github.com/ardalis/Specification/pull/513)
- Add a fallback to LINQ for search evaluators/validator in case of
custom user specifications. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#514](https://redirect.github.com/ardalis/Specification/pull/514)
- Update dependencies. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#526](https://redirect.github.com/ardalis/Specification/pull/526)
- Use opencover format for coverage reports. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#503](https://redirect.github.com/ardalis/Specification/pull/503)
- Added Full Build workflow that publishes coverage reports. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#504](https://redirect.github.com/ardalis/Specification/pull/504)
- Add benchmarks project. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#505](https://redirect.github.com/ardalis/Specification/pull/505)
- Cleanup by [@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#518](https://redirect.github.com/ardalis/Specification/pull/518)
- Add new test fixtures for EF6 provider. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#519](https://redirect.github.com/ardalis/Specification/pull/519)
- Add tests for EF6 evaluators. by
[@&#8203;fiseni](https://redirect.github.com/fiseni) in
[ardalis/Specification#520](https://redirect.github.com/ardalis/Specification/pull/520)

**Full Changelog**:
<ardalis/Specification@v9.2.0...v9.3.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/gritcsenko/HomeInventory).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS44MS4yIiwidXBkYXRlZEluVmVyIjoiNDEuODIuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
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

2 participants