Sunlix.NET.DDD.ROP
1.0.2
Prefix Reserved
dotnet add package Sunlix.NET.DDD.ROP --version 1.0.2
NuGet\Install-Package Sunlix.NET.DDD.ROP -Version 1.0.2
<PackageReference Include="Sunlix.NET.DDD.ROP" Version="1.0.2" />
<PackageVersion Include="Sunlix.NET.DDD.ROP" Version="1.0.2" />
<PackageReference Include="Sunlix.NET.DDD.ROP" />
paket add Sunlix.NET.DDD.ROP --version 1.0.2
#r "nuget: Sunlix.NET.DDD.ROP, 1.0.2"
#:package Sunlix.NET.DDD.ROP@1.0.2
#addin nuget:?package=Sunlix.NET.DDD.ROP&version=1.0.2
#tool nuget:?package=Sunlix.NET.DDD.ROP&version=1.0.2
Sunlix.NET.DDD.ROP
Sunlix.NET.DDD.ROP is a lightweight implementation of the Railway-Oriented Programming pattern for C#.
It provides a composable Result<TSuccess, TFailure> type and a set of functional operators for building clear and predictable execution pipelines without exceptions.
Table of Contents
Why this library
- Explicit error handling — no hidden control flow via exceptions
- Composable pipelines — chain operations in a predictable way
- Sync + async symmetry — every operator has async equivalent
- Minimal abstraction — no frameworks, just primitives
Installation
dotnet add package Sunlix.NET.DDD.ROP
Usage
This section contains minimal examples demonstrating the API.
All examples are intentionally simplified and focus only on behavior.
Result
Result<User, Error> result = Result.Succeed<User, Error>(user);
if (result.IsSuccess)
{
var value = result.Value;
}
Map / MapAsync
Transforms success value.
Result<User, Error> GetUser(int id) { ... }
UserDetails MapToDetails(User user) { ... }
Result<UserDetails, Error> result = GetUser(42)
.Map(MapToDetails);
Async:
async Task<UserDetails> MapToDetailsAsync(User user) { ... }
Result<UserDetails, Error> result = await GetUser(42)
.MapAsync(MapToDetailsAsync);
Bind / BindAsync
Chains operations that return Result.
Result<User, Error> GetUser(int id) { ... }
Result<Subscription, Error> GetSubscription(User user) { ... }
Result<Subscription, Error> result = GetUser(42)
.Bind(GetSubscription);
Async:
async Task<Result<Subscription, Error>> GetSubscriptionAsync(User user) { ... }
Result<Subscription, Error> result = await GetUser(42)
.BindAsync(GetSubscriptionAsync);
Tee / TeeAsync
Executes side effects on success.
void LogUser(User user) { ... }
Result<User, Error> result = GetUser(42)
.Tee(LogUser);
Async:
async Task LogUserAsync(User user) { ... }
Result<User, Error> result = await GetUserAsync(42)
.TeeAsync(LogUserAsync);
TeeError / TeeErrorAsync
Executes side effects on failure.
void LogError(Error error) { ... }
Result<User, Error> result = await GetUserAsync(42)
.TeeError(LogError);
Async:
async Task LogErrorAsync(Error error) { ... }
Result<User, Error> result = await GetUserAsync(42)
.TeeErrorAsync(LogErrorAsync);
FAQ
<details> <summary>Why not use exceptions?</summary>
Exceptions are for unexpected failures.
This library models expected outcomes explicitly via Result.
</details>
<details> <summary>When to use Map vs Bind?</summary>
- Use Map when transforming a value
- Use Bind when the function returns another
Result
</details>
<details> <summary>Can I mix sync and async?</summary>
Yes. Every operation has async equivalents, and they compose naturally.
</details>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- Sunlix.NET.DDD.BaseTypes (>= 1.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.2 - 2026-01-05
Fixed
- Fixed XML documentation.