Skip to content

Commit a8ff4a8

Browse files
committed
Update docs
1 parent 49cc6f9 commit a8ff4a8

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

docs/guide/troubleshooting.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,33 @@ Generated/
5151
| `InterceptsLocationAttribute.g.cs` | Interceptor attribute for compile-time call redirection |
5252
| `*_FoundatioModuleAttribute.g.cs` | Module marker for cross-assembly handler discovery |
5353

54+
### Viewing All Registered Handlers
55+
56+
The easiest way to see which handlers are registered at runtime is to use the `ShowRegisteredHandlers()` method:
57+
58+
```csharp
59+
var mediator = serviceProvider.GetRequiredService<IMediator>();
60+
((Mediator)mediator).ShowRegisteredHandlers();
61+
```
62+
63+
This logs all registered handlers to your configured logger:
64+
65+
```
66+
Registered Handlers:
67+
- Message: MyApp.Messages.CreateOrder, Handler: OrderHandler_CreateOrder_Handler, IsAsync: True
68+
- Message: MyApp.Messages.GetUser, Handler: UserHandler_GetUser_Handler, IsAsync: True
69+
- Message: MyApp.Messages.UserCreated, Handler: NotificationHandler_UserCreated_Handler, IsAsync: False
70+
```
71+
72+
**If a handler is missing from this list:**
73+
- Verify the class name ends with `Handler` or `Consumer`
74+
- Check that the method name is `Handle`, `HandleAsync`, `Consume`, or `ConsumeAsync`
75+
- Ensure the handler isn't marked with `[FoundatioIgnore]`
76+
- Handlers nested in generic classes are not supported (e.g., `OuterClass<T>.MyHandler`)
77+
- Verify `AddHandlers()` was called during DI configuration
78+
79+
For deeper inspection, you can also [view the generated source files](#enabling-generated-file-output) to see the actual registration code in `*_MediatorHandlers.g.cs`.
80+
5481
### Example Generated Handler
5582

5683
Here's what a generated handler wrapper looks like:
@@ -92,6 +119,10 @@ internal static class OrderHandler_CreateOrder_Handler
92119
2. Handler method doesn't follow naming conventions (`Handle`, `HandleAsync`, `Consume`, `ConsumeAsync`)
93120
3. Handler is in a different assembly and not registered
94121
4. Missing call to `AddHandlers()` in DI configuration
122+
5. Handler is nested inside a generic class (not supported)
123+
124+
**Debugging:**
125+
Use [`ShowRegisteredHandlers()`](#viewing-all-registered-handlers) to see which handlers are currently registered at runtime.
95126

96127
**Solutions:**
97128
```csharp

0 commit comments

Comments
 (0)