Repository navigation
Releases
Releases · a7mdfre7at/Masterly.Specification
Release v2.0.0
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 satisfiedSpecifications.AtLeast(n)- At least N specifications must be satisfiedSpecifications.AtMost(n)- At most N specifications must be satisfiedSpecifications.NoneOf()- None of the specifications should be satisfied
Fluent Builder
Spec.For<T>()- Start building a specification with fluent APISpec.Where<T>()- Create a simple specification from expressionSpec.Any<T>()- Factory method for always-true specificationSpec.None<T>()- Factory method for always-false specificationSpecificationBuilder<T>- Fluent builder withWhere(),And(),Or(),AndNot(),Not(),Xor(),Group(),OrGroup(), andBuild()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 trueSkipWhen()- Skip specification when condition is trueChain()- Chain multiple specifications togetherAsOptional()- Handle nullable specifications gracefullyConditionalSpecification<T>- Apply different specs based on entity predicatePipelineExtensions.When().Otherwise()- Fluent conditional builderOtherwisePass()- Pass all when condition not metOtherwiseFail()- Fail all when condition not metOrElse()- Short-circuit OR evaluationAndThen()- Short-circuit AND evaluation
Diagnostics & Explanation
Explain()- Generate human-readable specification descriptionEvaluate()- Get detailed evaluation results with pass/fail informationGetDetailedResult()- Get formatted output with all condition resultsEvaluationResult- Result class withIsSatisfied,Summary,GetPassedConditions(),GetFailureReasons()
Performance & Caching
Cached()- Cache compiled expression for repeated evaluationsCompile()- Get compiled delegate for maximum performanceMemoized()- Cache evaluation results per entity instanceCachedSpecification<T>- Specification wrapper withCompiledPredicateproperty
Changed
- Extended
SpecificationExtensionswith 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