Masterly.Specification
2.0.0
dotnet add package Masterly.Specification --version 2.0.0
NuGet\Install-Package Masterly.Specification -Version 2.0.0
<PackageReference Include="Masterly.Specification" Version="2.0.0" />
<PackageVersion Include="Masterly.Specification" Version="2.0.0" />
<PackageReference Include="Masterly.Specification" />
paket add Masterly.Specification --version 2.0.0
#r "nuget: Masterly.Specification, 2.0.0"
#:package Masterly.Specification@2.0.0
#addin nuget:?package=Masterly.Specification&version=2.0.0
#tool nuget:?package=Masterly.Specification&version=2.0.0
Masterly.Specification
Specification Pattern is used to define named, reusable, combinable and testable filters for entities and other business objects.
For more details, please take a look on the documentation on Github.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Ardalis.GuardClauses (>= 5.0.0)
- JetBrains.Annotations (>= 2025.2.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
# What's New
## Added
### Advanced Logic Operators
- **XOR Specification** (`Xor()`) - Returns true when exactly one specification is satisfied
- **Implies Specification** (`Implies()`) - Material implication (A → B), returns false only when A is true and B is false
- **Iff Specification** (`Iff()`) - Biconditional/equivalence, returns true when both have same truth value
- **NAND Specification** (`Nand()`) - Returns true unless both specifications are true
- **NOR Specification** (`Nor()`) - Returns true only when both specifications are false
### N-ary Composition
- **`Specifications.All()`** - All specifications must be satisfied (N-ary AND)
- **`Specifications.AnyOf()`** - At least one specification must be satisfied (N-ary OR)
- **`Specifications.Exactly(n)`** - Exactly N specifications must be satisfied
- **`Specifications.AtLeast(n)`** - At least N specifications must be satisfied
- **`Specifications.AtMost(n)`** - At most N specifications must be satisfied
- **`Specifications.NoneOf()`** - None of the specifications should be satisfied
### Fluent Builder
- **`Spec.For<T>()`** - Start building a specification with fluent API
- **`Spec.Where<T>()`** - Create a simple specification from expression
- **`Spec.Any<T>()`** - Factory method for always-true specification
- **`Spec.None<T>()`** - Factory method for always-false specification
- **`SpecificationBuilder<T>`** - Fluent builder with `Where()`, `And()`, `Or()`, `AndNot()`, `Not()`, `Xor()`, `Group()`, `OrGroup()`, and `Build()` methods
### Property-Based Specifications
- **`Property<T>.For()`** - Create type-safe specifications for entity properties
- **Comparison operators**: `EqualTo()`, `NotEqualTo()`, `GreaterThan()`, `LessThan()`, `GreaterThanOrEqual()`, `LessThanOrEqual()`
- **Range operators**: `InRange()`, `In()`, `NotIn()`
- **Null checks**: `IsNull()`, `IsNotNull()`
- **String operations**: `StartsWith()`, `EndsWith()`, `Contains()`, `IsNullOrEmpty()`, `HasContent()`, `HasLengthBetween()`
- **Custom predicates**: `Matches()`
### Temporal Specifications
- **`Temporal<T>.For()`** - Create specifications for DateTime properties
- **Date comparisons**: `Before()`, `After()`, `Between()`
- **Calendar filtering**: `InYear()`, `InMonth()`, `OnDayOfWeek()`, `OnWeekend()`, `OnWeekday()`
- **Time filtering**: `TimeBetween()`
- **Nullable support**: `HasValue()`, `IsNull()`
### Pipeline & Conditional
- **`OnlyWhen()`** - Apply specification only when condition is true
- **`SkipWhen()`** - Skip specification when condition is true
- **`Chain()`** - Chain multiple specifications together
- **`AsOptional()`** - Handle nullable specifications gracefully
- **`ConditionalSpecification<T>`** - Apply different specs based on entity predicate
- **`PipelineExtensions.When().Otherwise()`** - Fluent conditional builder
- **`OtherwisePass()`** - Pass all when condition not met
- **`OtherwiseFail()`** - Fail all when condition not met
- **`OrElse()`** - Short-circuit OR evaluation
- **`AndThen()`** - Short-circuit AND evaluation
### Diagnostics & Explanation
- **`Explain()`** - Generate human-readable specification description
- **`Evaluate()`** - Get detailed evaluation results with pass/fail information
- **`GetDetailedResult()`** - Get formatted output with all condition results
- **`EvaluationResult`** - Result class with `IsSatisfied`, `Summary`, `GetPassedConditions()`, `GetFailureReasons()`
### Performance & Caching
- **`Cached()`** - Cache compiled expression for repeated evaluations
- **`Compile()`** - Get compiled delegate for maximum performance
- **`Memoized()`** - Cache evaluation results per entity instance
- **`CachedSpecification<T>`** - Specification wrapper with `CompiledPredicate` property
## Changed
- Extended `SpecificationExtensions` with advanced logic operators
- Improved expression tree handling for all composite specifications
## Infrastructure
- Added comprehensive unit tests for all new features (101 tests)
- Updated test project to use xUnit.v3 and Shouldly
- Updated to .NET 9.0 for test project
- Added GlobalUsings.cs for test namespace imports