Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Jun 14, 2025

Fixes #516

@fiseni fiseni requested a review from Copilot June 14, 2025 15:10
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 projection extension and internal state copying by removing the old CopyTo hook on ISpecification<T>, introducing a Clone API on Specification<T>, and updating WithProjectionOf to leverage Clone<TResult>. It also cleans up unused explicit interface implementations in custom spec test classes and adds tests for the new Clone methods.

  • Removed ISpecification<T>.CopyTo and related explicit implementations in test fixtures
  • Added Clone() and Clone<TResult>() (with a shared CopyState helper) in Specification<T>
  • Updated SpecificationExtensions.WithProjectionOf to accept Specification<T> and use Clone<TResult>
  • Introduced unit tests verifying Clone behavior

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Ardalis.Specification.Tests/Validators/SearchValidatorCustomSpecTests.cs Removed unused ISpecification<T>.CopyTo impl
tests/Ardalis.Specification.Tests/Evaluators/SearchMemoryEvaluatorCustomSpecTests.cs Removed unused ISpecification<T>.CopyTo impl
tests/Ardalis.Specification.EntityFrameworkCore.Tests/Evaluators/SearchEvaluatorCustomSpecTests.cs Removed unused ISpecification<T>.CopyTo impl
tests/Ardalis.Specification.Tests/SpecificationTests.cs Added Clone and Clone<TResult> unit tests
src/Ardalis.Specification/SpecificationExtensions.cs Changed WithProjectionOf to accept Specification<T> and use Clone<TResult>
src/Ardalis.Specification/Specification.cs Introduced Clone(), Clone<TResult>(), and CopyState helper
src/Ardalis.Specification/ISpecification.cs Removed internal void CopyTo member
Comments suppressed due to low confidence (2)

src/Ardalis.Specification/SpecificationExtensions.cs:20

  • Changing WithProjectionOf to only accept Specification<T> is a breaking API change. Consider documenting this in the changelog and updating XML docs to guide consumers through the new usage.
public static Specification<T, TResult> WithProjectionOf<T, TResult>(this Specification<T> source, Specification<T, TResult> projectionSpec)

tests/Ardalis.Specification.Tests/SpecificationTests.cs:21

  • [nitpick] There are no unit tests covering the new WithProjectionOf extension. Adding a test to verify that projection selectors and post-processing actions are correctly copied would increase confidence in this change.
[Fact]

@fiseni fiseni merged commit f37fb7e into main Jun 14, 2025
1 check passed
@fiseni fiseni deleted the fiseni/withprojectionof-refactoring branch June 14, 2025 15:12
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.

Redefine WithProjectionOf as an extension to Specification instead of ISpecification
1 participant