ardalis/Specification
50.8
Adequate · 21 September 2026
5.8k
lines of production code
C#
primary language
4
measurements over time
What this system is
This system is a .NET library that implements the Specification and Repository patterns to simplify and standardize data access logic. It provides a fluent API for constructing complex queries, including filtering, sorting, pagination, and projections, which are then translated into efficient Entity Framework Core and EF6 database operations. The architecture features a modular evaluator system that applies these specifications to queries, supporting both in-memory and database-backed repositories with full test coverage.
Features
Add new exception types for specification validation errors
The library now includes new exception classes to provide clearer error messages when invalid specification configurations are detected. Specifically, it adds ConcurrentSelectorsException, DuplicateOrderChainException, DuplicateSkipException, DuplicateTakeException, InvalidSearchPatternException, and SelectorNotFoundException. These exceptions are thrown to enforce rules such as using only one selector transform, avoiding duplicate Skip/Take calls, and ensuring required selectors are defined.
src/Ardalis.Specification/Exceptions · high confidence
Add sample applications demonstrating specification usage and repository patterns
Added three sample applications (App1, App2, App3) that progressively demonstrate the library's features. App1 shows basic repository usage with built-in implementations. App2 introduces read repositories, custom specification evaluators, and direct DbContext usage. App3 adds pagination, filtering, and AutoMapper projection support with custom repository base classes. The domain models (Customer, Address) and specification classes are also included.
samples · high confidence
Added .editorconfig and solution structure for consistent code formatting and project organization
The repository now includes an .editorconfig file that enforces consistent coding styles, indentation, and naming conventions across C\# and VB files, alongside a new solution file that organizes the core library, Entity Framework Core and Entity Framework 6 integration projects, their respective test suites, and sample applications into a structured hierarchy. This change standardizes the development environment and project layout for all contributors.
(repo-wide) · high confidence
Introduces new evaluators and repository implementations for Entity Framework 6 and Entity Framework Core
The library now provides dedicated evaluator classes (AsNoTracking, Include, Order, Search, and Specification) that process query specifications for both Entity Framework 6 and Entity Framework Core. These evaluators handle query transformations such as filtering, sorting, and including related data. Additionally, the update introduces \RepositoryBase\ implementations for both EF6 and EF Core, which utilize these evaluators to execute database operations like \AddAsync\, \UpdateAsync\, and \ListAsync\. For EF Core, a \ContextFactoryRepositoryBaseOfT\ is also added to support scoped repository creation via \IDbContextFactory\. This change restructures how specifications are applied to queries, moving the logic into specialized evaluator classes that are then used by the repository base classes.
src/Ardalis.Specification.EntityFramework6 · high confidence
New query execution and filtering evaluators for Entity Framework Core
The library introduces a suite of new evaluators that allow users to configure EF Core query behaviors directly through specifications. These include AsNoTracking, AsNoTrackingWithIdentityResolution, AsSplitQuery, AsTracking, IgnoreAutoIncludes, IgnoreQueryFilters, Include, IncludeString, Order, Pagination, QueryTag, and Search. The SpecificationEvaluator now orchestrates these evaluators to apply the corresponding EF Core extension methods (e.g., .AsNoTracking(), .TagWith()) to the generated queries, giving users fine-grained control over tracking, splitting, and query tagging.
src/Ardalis.Specification.EntityFrameworkCore/Evaluators · high confidence
New specification builder methods for caching, filtering, and querying
The specification builder now supports setting cache keys via \EnableCache\ and \WithCacheKey\, allowing applications to control caching behavior. New methods \IgnoreQueryFilters\ and \IgnoreAutoIncludes\ provide conditional control over query filtering and auto-includes. Query construction is enhanced with \Include\ and \ThenInclude\ for navigation properties, \OrderBy\/\ThenBy\ for sorting, \Take\/\Skip\ for pagination, and \Search\ for pattern matching. Additional capabilities include \PostProcessingAction\ for in-memory result transformation, \Select\/\SelectMany\ for projection, and \TagWith\ for query tagging.
src/Ardalis.Specification/Builders · high confidence
Behavioural changes
Introduce internal OneOrMany struct and supporting utilities
The internal implementation of the specification library has been refactored to use a new \OneOrMany\<T\>\ struct, which efficiently manages collections that may contain a single item or multiple items, optimizing memory usage by avoiding unnecessary list allocations for single values. This change is accompanied by the addition of a \CollectionExtensions\ helper to optimize list conversions and a \SearchExpressionComparer\ to handle sorting of search expressions, supporting the consolidation of state management for where and search expressions.
src/Ardalis.Specification/Internals · medium confidence
Introduces dedicated expression info classes for query components
The library now uses specific wrapper classes—IncludeExpressionInfo, OrderExpressionInfo, SearchExpressionInfo, and WhereExpressionInfo—each encapsulating the data required for their respective query operations (such as filtering, sorting, searching, and including related entities). This refactoring simplifies the internal representation of expression states, making the specification's handling of these components more explicit and organized.
src/Ardalis.Specification/Expressions · high confidence
Refactored specification evaluators and validators into a modular, extensible architecture
The specification evaluation and validation logic has been restructured into a modular, interface-driven architecture. New interfaces (IEvaluator, IInMemoryEvaluator, ISpecificationEvaluator, IValidator, IInMemorySpecificationEvaluator) and their implementations (WhereEvaluator, SearchMemoryEvaluator, OrderEvaluator, PaginationEvaluator, SpecificationValidator, etc.) replace the previous monolithic evaluators. This change improves memory efficiency and allows for easier extension or replacement of specific evaluation/validator behaviors. A fallback mechanism is also introduced for custom user specifications to ensure compatibility.
src/Ardalis.Specification/Evaluators · high confidence
Refactored specification state management and added projection support
The internal state of specifications has been refactored to reduce memory allocations and improve performance, utilizing a new \OneOrMany\ collection type for expressions. This change introduces \ISingleResultSpecification\ interfaces and \SingleResultSpecification\ classes to constrain methods that return a single result. Additionally, a \WithProjectionOf\ extension method is now available to apply a projection specification to an existing specification, creating a new specification with the combined select logic.
src/Ardalis.Specification · high confidence
Test coverage
Add Ardalis.Specification.Benchmarks project for performance regression tracking; Add unit tests for specification evaluators and validators; Added EF6 test fixture and integration test infrastructure; Added benchmark data models and context; Added integration tests for EF6 Repository operations; Added integration tests for EF6 specification evaluators; Added integration tests for Entity Framework Core specification extensions; Added integration tests for complex query and select operations; Added integration tests for repository operations; Added test infrastructure for EF6 provider; Added unit and integration tests for EF Core query evaluators; Added unit tests for Specification cloning, projection, and size; Added unit tests for expression info classes; Added unit tests for internal specification components; Added unit tests for specification builder methods.
Dependencies
Upgrade to .NET 9 and EF Core 9.0.8
The project has been upgraded to target .NET 9, with the core specification library and its Entity Framework Core plugin now supporting both .NET 8 and .NET 9. This update brings EF Core 9.0.8 for .NET 9 targets, while maintaining EF Core 8.0.19 for .NET 8. Additionally, the solution now uses central package version management via Directory.Packages.props, and sample applications have been added to demonstrate the updated stack.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 49 → 51 (+1.9)
- Rubric changed (rubric-2026.08.18 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 90 → 89 (-0.8)
- Architecture 99 → 99 (+0.0)
- Maturity 59 → 59 (+0.0)
- Readiness 31 → 32 (+1.2)
- Security 65 → 73 (+7.9)
- Domain Modelling 63 → 71 (+7.7)
- Performance 69 → 69 (-0.3)
Resolved (15)
- Bounded contexts not declared
- Duplicated block (28 lines × 2) (src/Ardalis.Specification/Evaluators/SearchMemoryEvaluator.cs)
- Duplicated block (6 lines × 3) (samples/Ardalis.Sample.App1/WebApplicationExtensions.cs)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- LLM evaluation failed
- LLM evaluation failed
- No exposed public API
- Off-boarding risk: anonymized user #1
- Test runner surfaced no tests
New (40)
- CoverageExclusion (src/Ardalis.Specification/Evaluators/Iterator.cs)
- CoverageExclusion (src/Ardalis.Specification/Evaluators/Iterator.cs)
- CoverageExclusion (src/Ardalis.Specification/Evaluators/Iterator.cs)
- Documentation: no installation or build instructions (docs/getting-started/index.md)
- Duplicated block (10 lines × 4) (samples/Ardalis.Sample.App3/IReadRepository.cs)
- Duplicated block (12 lines × 2) (src/Ardalis.Specification/Builders/Builder_Include.cs)
- Duplicated block (16 lines × 2) (src/Ardalis.Specification.EntityFrameworkCore/Evaluators/SearchExtension.cs)
- Duplicated block (29 lines × 2) (src/Ardalis.Specification.EntityFramework6/Evaluators/OrderEvaluator.cs)
- Duplicated block (30 lines × 2) (src/Ardalis.Specification/Evaluators/SearchMemoryEvaluator.cs)
- Duplicated block (6 lines × 3) (samples/Ardalis.Sample.App1/WebApplicationExtensions.cs)
- Duplicated block (7 lines × 2) (src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs)
- Duplicated block (7 lines × 2) (src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs)
- Duplicated block (7 lines × 2) (src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs)
- Duplicated block (8 lines × 2) (samples/Ardalis.Sample.App2/Program.cs)
- Edited copy of a member (29 corresponding lines) (src/Ardalis.Specification.EntityFramework6/Evaluators/OrderEvaluator.cs)
- End-of-life runtime: .NET net9.0
- High CVE: SSH.NET 2024.2.0
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 20 more
API surface
- Unchanged — 7 HTTP endpoints
Architecture
- Unchanged — 1 containers · 1 contexts · 0 edges
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
ardalis/Specification was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit d2fcf351a97b4887829bddac424a12d8a3eaf9fe — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.