Attribute Reference¶
The Effects module uses four attributes to declare effect modules, runtimes, and capabilities.
[EffectsModule]¶
Marks a partial class as an effect module wrapping a target type. Apply multiple times to group related services into a single module class.
| Property | Type | Default | Description |
|---|---|---|---|
TargetType |
Type |
(required) | The interface to wrap |
Name |
string? |
Inferred | Module name used in the nested class and capability interface |
Instrumented |
bool |
true |
Whether to generate OpenTelemetry instrumentation |
IncludeOnly |
string[]? |
null |
Only wrap these methods (by name) |
Exclude |
string[]? |
null |
Exclude these methods (by name) |
[EffectsModule(typeof(INotificationChannel))]
[EffectsModule(typeof(INotificationStore))]
public sealed partial class NotificationsModule;
This generates a static partial class NotificationsModule containing nested static classes NotificationChannel and NotificationStore, each with effect methods for their respective interface.
Rules and Constraints¶
- The target type should be an interface — targeting a concrete class raises DSEFX03
- The module class must be
partial(DSEFX01) and should besealed(DSEFX02) - A target type can only appear once per module class (DSEFX04)
- If the target has no methods, DSEFX07 is raised
Method Filtering¶
Use IncludeOnly or Exclude to control which methods get wrapped:
// Only wrap SendAsync — skip ValidateAsync
[EffectsModule(typeof(IEmailService), IncludeOnly = ["SendAsync"])]
public sealed partial class EmailEffects;
// Wrap everything except Dispose
[EffectsModule(typeof(IEmailService), Exclude = ["Dispose"])]
public sealed partial class EmailEffects;
Warning
Specifying a method name that doesn't exist on the target raises DSEFX05 (for Exclude) or DSEFX06 (for IncludeOnly) at compile time.
Disabling Instrumentation¶
Set Instrumented = false to skip OpenTelemetry instrumentation for a module:
[EffectsModule(typeof(IEmailService), Instrumented = false)]
public sealed partial class EmailEffects;
[Runtime], [Uses]¶
See the Runtime page for [Runtime], [Uses], and [Capability] attribute reference.
[Capability]¶
Declares a raw service dependency on the runtime without generating effect wrapper methods. Use this for services accessed directly (e.g., configuration roots) that don't need Eff lifting or instrumentation.
For config access in effects, prefer [ConfigModule]
[ConfigModule] generates typed effect accessors for configuration. Use [Capability] only when you need the full interface as a direct runtime dependency. See Effects Composition for details.
| Property | Type | Description |
|---|---|---|
TargetType |
Type |
The interface to expose as a capability |
[EffectsModule(typeof(INotifier))]
[Capability(typeof(IWorkshopConfigRoot))]
public sealed partial class WorkshopEffects;
This generates an IHasWorkshopConfigRoot interface with a property, but no effect methods. The dependency is still wired into the runtime and resolved via DI.