Namespace Trellis
Classes
- AggregateError
Represents an aggregate of multiple errors that occurred together. Use this when multiple independent errors need to be returned as a single failure result.
- Aggregate<TId>
Base class for aggregate roots in Domain-Driven Design. An aggregate is a cluster of domain objects (entities and value objects) that form a consistency boundary. The aggregate root is the only entry point for modifications and ensures all invariants within the boundary are maintained.
- BadRequestError
Represents a bad request error indicating the request was malformed or syntactically invalid. Use this for requests that cannot be processed due to syntax errors, missing required data, or malformed content. Maps to HTTP 400 Bad Request.
- BindExtensions
Provides extension methods for binding (chaining) operations over Result values.
- BindExtensionsAsync
Provides asynchronous extension methods for binding (chaining) operations over Result values.
- CombineErrorExtensions
Combine errors into one. If both the errors types are ValidationError, the validation errors will be merged. Otherwise, the errors will be wrapped into an AggregateError.
- CombineExtensions
Combines two or more Result<TValue> into one tuple containing all the Results.
- CombineExtensionsAsync
Combines two or more Result<TValue> into one tuple containing all the Results.
- ConflictError
Represents a conflict error indicating the request conflicts with the current state of the resource. Use this when an operation cannot be completed due to a conflict with existing data or state. Maps to HTTP 409 Conflict.
- DomainError
Represents a domain or business rule violation. Use this for errors that occur when domain logic or business rules prevent an operation from completing. Maps to HTTP 422 Unprocessable Entity.
- EnsureExtensions
Provides extension methods for ensuring conditions on Result values. If conditions fail, the result is converted to a failure with the specified error.
- EnsureExtensionsAsync
Async Ensure extensions where BOTH input and predicates are async (Task).
- Entity<TId>
Base class for entities in Domain-Driven Design. An entity is a domain object defined by its identity rather than its attributes. Two entities with different attributes but the same ID are considered equal.
- Error
Base class for all error types in the functional DDD library. Errors represent failure states and contain structured information about what went wrong.
- ForbiddenError
Represents a forbidden error when an authenticated user lacks permission to access a resource. Use this when the user is authenticated but does not have the required authorization or role. Maps to HTTP 403 Forbidden.
- MapExtensions
Provides extension methods for mapping (transforming) values inside Result objects.
- MapExtensionsAsync
Provides asynchronous extension methods for mapping (transforming) values inside Result objects.
- MapOnFailureExtensions
Provides extension methods for transforming errors in failed Results while leaving successful Results unchanged.
- MatchErrorExtensions
Pattern matching helpers for discriminating specific error types in Result. Allows matching on specific error types (ValidationError, NotFoundError, etc.) rather than treating all errors the same.
- MatchErrorExtensionsAsync
Asynchronous pattern matching helpers for discriminating specific error types in Result.
- MatchExtensions
Pattern matching helpers (Match / Switch) for Result.
- MatchExtensionsAsync
Asynchronous pattern matching helpers for Result.
- MaybeExtensions
Provides extension methods for converting Maybe<T> instances to Result<TValue> objects and for wrapping values in a Result<TValue>.
- MaybeExtensionsAsync
Provides asynchronous extension methods for converting Maybe<T> instances to Result<TValue>.
- NotFoundError
Represents a "not found" error when a requested resource does not exist. Use this when an entity, record, or resource cannot be located. Maps to HTTP 404 Not Found.
- NullableExtensions
Extension methods for converting nullable values to Result types. Provides a convenient way to handle null checking with Railway Oriented Programming.
- NullableExtensionsAsync
Asynchronous extension methods for converting nullable values to Result types.
- ParsableJsonConverter<T>
A JSON converter for value objects that implement IParsable<TSelf>. Enables automatic serialization and deserialization of parsable value objects in ASP.NET Core APIs and System.Text.Json scenarios.
- PrimitiveValueObjectTrace
Provides OpenTelemetry activity tracing for Primitive Value Objects operations. Enables monitoring and diagnostics of value object creation, validation, and parsing activities.
- PrimitiveValueObjectTraceProviderBuilderExtensions
Provides extension methods for configuring OpenTelemetry tracing for Primitive Value Objects (PVO).
- RailwayTrackAttribute
Indicates which railway track an operation executes on. This metadata can be used by IDE extensions, analyzers, and documentation generators.
- RateLimitError
Represents a rate limiting error when too many requests have been made. Use this when a client has exceeded their request quota or rate limit. Maps to HTTP 429 Too Many Requests.
- RecoverOnFailureExtensions
Provides extension methods for recovering from failed results by executing fallback operations.
- RecoverOnFailureExtensionsAsync
Provides asynchronous extension methods for recovering from failed results.
- RequiredDecimal<TSelf>
Base class for creating strongly-typed decimal value objects that cannot have the default (zero) value. Provides a foundation for monetary amounts, percentages, and other domain concepts represented by decimals.
- RequiredEnumJsonConverter<TRequiredEnum>
JSON converter for RequiredEnum<TSelf> types. Serializes to the string Name and deserializes from string name.
- RequiredEnum<TSelf>
Base class for creating strongly-typed, behavior-rich enumeration value objects. Enum value objects are a DDD pattern that replaces C# enums with full-featured classes.
- RequiredGuid<TSelf>
Base class for creating strongly-typed GUID value objects that cannot have the default (empty) GUID value. Provides a foundation for entity identifiers and other domain concepts represented by GUIDs.
- RequiredInt<TSelf>
Base class for creating strongly-typed integer value objects that cannot have the default (zero) value. Provides a foundation for entity identifiers, counts, and other domain concepts represented by integers.
- RequiredString<TSelf>
Base class for creating strongly-typed string value objects that cannot be null or empty. Provides a foundation for domain primitives like names, descriptions, codes, and other textual concepts.
- ResultDebugExtensions
Debug extension methods for inspecting Result values during development. These methods execute only in DEBUG builds and become no-ops in RELEASE builds (with zero overhead).
- ResultDebugExtensionsAsync
Debug-only async extension methods for inspecting Result values during development. These methods are only available in DEBUG builds and are automatically excluded from RELEASE builds. Debug information is written to dedicated Activity spans for OpenTelemetry compatibility.
- ResultLinqExtensions
Provides LINQ query expression support for Result types, enabling C# query syntax for functional operations.
- ResultsTraceProviderBuilderExtensions
Extension methods for configuring OpenTelemetry tracing for Railway Oriented Programming operations.
- ScalarValueObject<TSelf, T>
Base class for value objects that wrap a single scalar value. Provides a strongly-typed wrapper around primitive types with domain semantics.
- ServiceUnavailableError
Represents a temporary service unavailability error. Use this when the service is temporarily unable to handle the request due to maintenance or overload. Maps to HTTP 503 Service Unavailable.
- TapExtensions
Provides extension methods for executing side effects on successful Results without changing the Result.
- TapExtensionsAsync
Provides asynchronous extension methods for executing side effects on successful Results without changing the Result.
- TapOnFailureExtensions
Provides extension methods for executing side effects on failed Results without changing the Result.
- TapOnFailureExtensionsAsync
Provides asynchronous extension methods for executing side effects on failed Results without changing the Result.
- TraverseExtensions
Transforms a collection of items into a Result containing a collection, short-circuiting on the first failure. Useful for processing collections where each item can fail independently.
- UnauthorizedError
Represents an authorization error when authentication is required but not provided. Use this when a user is not authenticated (not logged in) and must authenticate to access the resource. Maps to HTTP 401 Unauthorized.
- UnexpectedError
Represents an unexpected system error or exception. Use this for infrastructure failures, unhandled exceptions, or system-level errors. Maps to HTTP 500 Internal Server Error.
- ValidationError
Represents validation errors for one or more fields. Used when input data fails business rules or constraints.
- ValueObject
Base class for value objects in Domain-Driven Design. A value object represents a descriptive aspect of the domain with no conceptual identity. Value objects are immutable, defined by their attributes, and support structural equality.
- WhenExtensions
Conditionally executes an operation based on a predicate, maintaining the railway. Useful for executing operations only when certain conditions are met without breaking the Result chain.
- WhenExtensionsAsync
Asynchronous conditional execution operations for Result.
Structs
- Maybe<T>
Represents domain-level optionality — a value that was either provided or intentionally omitted. Unlike Nullable<T> (value types only) or
T?(annotation only for reference types), Maybe<T> is a real generic type that works uniformly with both value and reference types and composes with Result<TValue> pipelines.
- Result
Static Combine methods for combining multiple independent Result values without chaining.
- Result<TValue>
Represents either a successful computation (with a value) or a failure (with an Error).
- Unit
Represents the absence of a meaningful value, used for operations that have no return value. This is the functional programming equivalent of
void, but as a proper type that can be used with generics.
- ValidationError.FieldError
Represents an error for a specific field, which may have multiple detail messages.
Interfaces
- IAggregate
Defines the contract for an aggregate root in Domain-Driven Design. An aggregate is a cluster of domain objects that can be treated as a single unit for data changes.
- IDomainEvent
Represents a domain event - a record of something significant that happened in the business domain. Domain events capture state changes and business occurrences that domain experts care about.
- IResult
Non-generic base interface for result types, exposing success/failure state and error information.
- IResult<TValue>
Generic interface for result types, providing typed access to the success value.
- IScalarValue<TSelf, TPrimitive>
Interface for scalar value objects that can be created with validation. Enables automatic ASP.NET Core model binding and JSON serialization.
Enums
- TrackBehavior
Defines which railway track an operation runs on in Railway-Oriented Programming.