Summary
Introduce a Roslyn analyzer that generates a compile time warning when a class implementing IEffect injects either IDispatcher.
Problem
IEffect handlers are executed inside an existing StatePulse pipeline chain.
This chain is responsible for:
- propagation of cancellation
- anti duplication safeguards
- race condition protection
- ordered dispatch execution
If an IEffect directly injects and uses a new IDispatcher, it creates a new dispatch chain instead of continuing the existing one.
This detaches the execution flow from the current pipeline.
As a result:
- cancellation from the original pipeline are lost
- anti duplication guarantees are bypassed
- race condition protections are broken
- dispatch ordering guarantees are no longer enforced
Why This Matters
If the parent pipeline is cancelled, any dispatch started through an injected IDispatcher will continue executing independently.
This leads to:
- inconsistent state mutations
- duplicate effects
- race conditions between pipelines
Developers must be aware of this behavior at compile time.
Analyzer Behavior
Emit a warning diagnostic when:
A class:
AND
via constructor injection or field injection.
Example that should trigger the analyzer:
public class MyEffect : IEffect<MyAction>
{
private readonly IDispatcher _dispatcher;
public MyEffect(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
}
Summary
Introduce a Roslyn analyzer that generates a compile time warning when a class implementing
IEffectinjects eitherIDispatcher.Problem
IEffecthandlers are executed inside an existing StatePulse pipeline chain.This chain is responsible for:
If an
IEffectdirectly injects and uses a newIDispatcher, it creates a new dispatch chain instead of continuing the existing one.This detaches the execution flow from the current pipeline.
As a result:
Why This Matters
If the parent pipeline is cancelled, any dispatch started through an injected
IDispatcherwill continue executing independently.This leads to:
Developers must be aware of this behavior at compile time.
Analyzer Behavior
Emit a warning diagnostic when:
A class:
IEffectAND
IDispatchervia constructor injection or field injection.
Example that should trigger the analyzer: