You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight, opinionated C# mediator library focused on simplicity and clean design.
4
9
5
-
## Overview
10
+
## 📖 Overview
6
11
7
12
ResultR provides a minimal yet powerful mediator pattern implementation with built-in result handling, validation, and request lifecycle hooks. It's designed as a modern alternative to MediatR with a smaller surface area and a clearer result pattern.
8
13
9
-
## Key Features
14
+
## ✨ Key Features
10
15
11
-
-**Single Interface Pattern**: Uses only `IRequest<TResponse>` and `IRequestHandler<TRequest, TResponse>` - no distinction between commands and queries
12
-
-**Unified Result Type**: All operations return `Result<T>` or `Result`, supporting success/failure states, exception capture, and optional metadata
13
-
-**Optional Inline Hooks**: Handlers can override `ValidateAsync()`, `OnPreHandleAsync()`, and `OnPostHandleAsync()` methods without requiring base classes or separate interfaces
14
-
-**Request-Specific Logging**: Built-in support for per-request logging via `ILoggerFactory`
15
-
-**Minimal Configuration**: Simple DI integration with minimal setup
16
-
-**Strong Typing**: Full type safety throughout the pipeline
16
+
-🔌 **Single Interface Pattern**: Uses only `IRequest<TResponse>` and `IRequestHandler<TRequest, TResponse>` - no distinction between commands and queries
17
+
-📦 **Unified Result Type**: All operations return `Result<T>` or `Result`, supporting success/failure states, exception capture, and optional metadata
18
+
-🪝 **Optional Inline Hooks**: Handlers can override `ValidateAsync()`, `OnPreHandleAsync()`, and `OnPostHandleAsync()` methods without requiring base classes or separate interfaces
19
+
-📝 **Request-Specific Logging**: Built-in support for per-request logging via `ILoggerFactory`
20
+
-⚡ **Minimal Configuration**: Simple DI integration with minimal setup
21
+
-🔒 **Strong Typing**: Full type safety throughout the pipeline
17
22
18
-
## Design Philosophy
23
+
## 💡 Design Philosophy
19
24
20
25
ResultR prioritizes:
21
26
-**Simplicity over flexibility**: Opinionated design choices reduce boilerplate
22
27
-**Clean architecture**: No magic strings, reflection-heavy operations, or hidden behaviors
23
28
-**Explicit over implicit**: Clear pipeline execution with predictable behavior
24
29
-**Modern C# practices**: Leverages latest language features and patterns
25
30
26
-
## Pipeline Execution
31
+
## 🔄 Pipeline Execution
27
32
28
33
Each request flows through a simple, predictable pipeline:
29
34
30
-
1.**Validation** - Calls `ValidateAsync()` if overridden, short-circuits on failure
31
-
2.**Pre-Handle** - Invokes `OnPreHandleAsync()` for optional logging or setup
32
-
3.**Handle** - Executes the core `HandleAsync()` logic
33
-
4.**Post-Handle** - Invokes `OnPostHandleAsync()` for logging or cleanup
34
-
5.**Exception Handling** - Any exceptions are caught and returned as `Result.Failure` with the exception attached
35
+
1.✅ **Validation** - Calls `ValidateAsync()` if overridden, short-circuits on failure
36
+
2.🚀 **Pre-Handle** - Invokes `OnPreHandleAsync()` for optional logging or setup
37
+
3.⚙️ **Handle** - Executes the core `HandleAsync()` logic
38
+
4.🏁 **Post-Handle** - Invokes `OnPostHandleAsync()` for logging or cleanup
39
+
5.🛡️ **Exception Handling** - Any exceptions are caught and returned as `Result.Failure` with the exception attached
35
40
36
-
## Installation
41
+
## 📥 Installation
37
42
38
43
```bash
39
44
dotnet add package ResultR
40
45
```
41
46
42
-
## Quick Start
47
+
## 🚀 Quick Start
43
48
44
49
### 1. Define a Request
45
50
@@ -137,7 +142,7 @@ public class UserController : ControllerBase
137
142
}
138
143
```
139
144
140
-
## Result Type
145
+
## 📦 Result Type
141
146
142
147
The `Result<T>` type provides a clean way to handle success and failure states:
143
148
@@ -175,7 +180,7 @@ public async ValueTask<Result<Result>> HandleAsync(DeleteUserRequest request, Ca
175
180
}
176
181
```
177
182
178
-
## Advanced Features
183
+
## 🔧 Advanced Features
179
184
180
185
### Metadata Support
181
186
@@ -204,7 +209,7 @@ public class ValidatingHandler : IRequestHandler<MyRequest, MyResponse>
204
209
}
205
210
```
206
211
207
-
## Benchmarks
212
+
## 📊 Benchmarks
208
213
209
214
There are many great Mediator implementations out there. Here is a comparision between ResultR and some of the other popular ones:
210
215
@@ -233,7 +238,7 @@ cd src/ResultR.Benchmarks
233
238
dotnet run -c Release
234
239
```
235
240
236
-
## Why ResultR?
241
+
## 🤔 Why ResultR?
237
242
238
243
### vs MediatR
239
244
@@ -249,20 +254,20 @@ dotnet run -c Release
249
254
-**Type safety**: Compile-time guarantees for request/response matching
250
255
-**Extensibility**: Optional hooks without forcing inheritance
251
256
252
-
## Requirements
257
+
## 📋 Requirements
253
258
254
259
- .NET 10.0 or later
255
260
- C# 14.0 or later
256
261
257
-
## Contributing
262
+
## 🤝 Contributing
258
263
259
264
Contributions are welcome! Please feel free to submit a Pull Request.
260
265
261
-
## License
266
+
## 📄 License
262
267
263
268
ISC License - see LICENSE file for details
264
269
265
-
## Roadmap
270
+
## 🗺️ Roadmap
266
271
267
272
-[x] Core mediator implementation
268
273
-[x] Result types with metadata support
@@ -271,7 +276,7 @@ ISC License - see LICENSE file for details
0 commit comments