Class SideEffect
Represents a side effect produced by a mutation. Side effects capture additional consequences that are not part of the primary state change.
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Effects
Assembly: ModularityKit.Mutator.dll
Syntax
[JsonConverter(typeof(SideEffectJsonConverter))]
public sealed class SideEffect
Properties
| Edit this page View SourceData
Optional data associated with the side effect. Can hold structured information for logging, auditing, or downstream processing.
Declaration
public object? Data { get; init; }
Property Value
| Type | Description |
|---|---|
| object |
DataContractType
Stable contract identifier for typed side effect payloads.
Declaration
public string? DataContractType { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
DataContractVersion
Version number for typed side effect payloads.
Declaration
public int? DataContractVersion { get; init; }
Property Value
| Type | Description |
|---|---|
| int? |
Description
Human-readable description of the side effect.
Declaration
public string Description { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
RequiresAction
Indicates whether this side effect requires an explicit action or intervention.
Declaration
public bool RequiresAction { get; init; }
Property Value
| Type | Description |
|---|---|
| bool |
Severity
Severity of the side effect. Determines the criticality or importance for monitoring and alerting.
Declaration
public SideEffectSeverity Severity { get; init; }
Property Value
| Type | Description |
|---|---|
| SideEffectSeverity |
Timestamp
Timestamp when the side effect occurred.
Declaration
public DateTimeOffset Timestamp { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset |
Type
The type of the side effect (e.g., "Notification", "AuditLog", "ExternalCall").
Declaration
public string Type { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceCreate(string, string, object?, SideEffectSeverity, bool, DateTimeOffset?)
Creates a new SideEffect with the specified properties.
Declaration
public static SideEffect Create(string type, string description, object? data = null, SideEffectSeverity severity = SideEffectSeverity.Info, bool requiresAction = false, DateTimeOffset? timestamp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the side effect. |
| string | description | Human-readable description. |
| object | data | Optional associated data. When the payload type declares SideEffectDataContractAttribute, the side effect contract metadata is populated automatically. |
| SideEffectSeverity | severity | Severity level. |
| bool | requiresAction | Indicates whether the side effect requires explicit follow-up. Critical severity always implies action. |
| DateTimeOffset? | timestamp | Optional timestamp override. Defaults to current UTC time. |
Returns
| Type | Description |
|---|---|
| SideEffect |
Create<TData>(string, string, TData, SideEffectSeverity, bool, DateTimeOffset?)
Creates a new SideEffect with a typed payload contract.
Declaration
public static SideEffect Create<TData>(string type, string description, TData data, SideEffectSeverity severity = SideEffectSeverity.Info, bool requiresAction = false, DateTimeOffset? timestamp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the side effect. |
| string | description | Human-readable description. |
| TData | data | Typed associated payload. |
| SideEffectSeverity | severity | Severity level. |
| bool | requiresAction | Indicates whether the side effect requires explicit follow-up. Critical severity always implies action. |
| DateTimeOffset? | timestamp | Optional timestamp override. Defaults to current UTC time. |
Returns
| Type | Description |
|---|---|
| SideEffect |
Type Parameters
| Name | Description |
|---|---|
| TData | The payload type. |
Critical(string, string, object?, DateTimeOffset?)
Creates a new critical SideEffect instance.
Declaration
public static SideEffect Critical(string type, string description, object? data = null, DateTimeOffset? timestamp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the side effect. |
| string | description | Human-readable description. |
| object | data | Optional associated data. When the payload type declares SideEffectDataContractAttribute, the side effect contract metadata is populated automatically. |
| DateTimeOffset? | timestamp | Optional timestamp override. Defaults to current UTC time. |
Returns
| Type | Description |
|---|---|
| SideEffect |
Critical<TData>(string, string, TData, DateTimeOffset?)
Creates a new critical SideEffect instance with a typed payload contract.
Declaration
public static SideEffect Critical<TData>(string type, string description, TData data, DateTimeOffset? timestamp = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the side effect. |
| string | description | Human-readable description. |
| TData | data | Typed associated payload. |
| DateTimeOffset? | timestamp | Optional timestamp override. Defaults to current UTC time. |
Returns
| Type | Description |
|---|---|
| SideEffect |
Type Parameters
| Name | Description |
|---|---|
| TData | The payload type. |
TryGetData<TData>(out TData?)
Attempts to read the side effect payload as a typed contract.
Declaration
public bool TryGetData<TData>(out TData? data)
Parameters
| Type | Name | Description |
|---|---|---|
| TData | data | The typed payload when available. |
Returns
| Type | Description |
|---|---|
| bool | true when the payload is available as |
Type Parameters
| Name | Description |
|---|---|
| TData | The expected payload type. |