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 08:25
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 refactors the handling of order expressions by transitioning from a List to a OneOrMany data structure, aiming to simplify and standardize the state management of order expressions. Key changes include:

  • Renaming unit tests to more accurately reflect the type of order chain (OrderBy vs. OrderByDescending) and adding a new test for handling invalid root chains.
  • Updating the Specification class to use OneOrMany<OrderExpressionInfo> instead of a List.
  • Modifying the OrderEvaluator logic to use new OneOrMany order expression properties and to enhance duplicate order chain detection.

Reviewed Changes

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

File Description
tests/Ardalis.Specification.Tests/Evaluators/OrderEvaluatorTests.cs Updated unit tests to reflect new ordering constraints and exception expectations.
src/Ardalis.Specification/Specification.cs Refactored order expressions to utilize OneOrMany and updated cloning/adding logic accordingly.
src/Ardalis.Specification/Evaluators/OrderEvaluator.cs Modified evaluator logic to process OneOrMany order expressions and adjusted duplicate order chain validation.
Comments suppressed due to low confidence (1)

src/Ardalis.Specification/Specification.cs:194

  • Verify that the Clone method on OneOrMany properly creates a deep copy as needed to avoid unintended shared state between specifications.
otherSpec._orderExpressions = _orderExpressions.Clone();

@fiseni fiseni merged commit a01c57e into main Jun 13, 2025
1 check passed
@fiseni fiseni deleted the fiseni/oneormany-order branch June 13, 2025 08:36
@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 Sep 2, 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