Version 1.0.2 addresses critical user feedback regarding async operations in state machine callbacks. This release introduces compile-time safety through Roslyn analyzers, runtime validation, and comprehensive documentation to prevent common pitfalls when working with async operations in Stateless state machines.
Two new analyzers provide immediate feedback during development:
- OSMES001: Warns about async lambdas in state callbacks (OnEntry, OnExit)
- OSMES002: Errors on FireAsync calls within callbacks
These analyzers catch common mistakes at compile time, preventing runtime issues before they occur.
- Added thread-local state tracking to detect callback execution context
FireAsyncmethods now throwInvalidOperationExceptionif called from within callbacks- Clear, actionable error messages guide developers to correct patterns
- Event Replay Failures: Now include event index, state transition details, and timestamps
- Invalid State Transitions: Display permitted triggers and current state context
- Callback Violations: Provide clear guidance on moving logic to grain methods
- New
ASYNC_PATTERNS.mdguide with:- Clear examples of what NOT to do
- Multiple correct implementation patterns
- Complete workflow examples
- Best practices for async operations
- Prominent warnings in README about Stateless async limitations
- Compile-time analyzers prevent common mistakes
- Runtime validation catches issues with clear error messages
- Detailed documentation helps developers understand proper patterns
EventReplayExceptionnow includes event context and failure details- All error messages provide actionable guidance
- Stack traces include relevant state machine context
None. All changes are backward compatible.
- Fixed duplicate
EventReplayExceptionclass definition - Resolved analyzer warning format issues
- Fixed test compilation errors with proper namespace usage
- Added comprehensive Async Patterns Guide
- Updated README with async operation warnings
- Added analyzer documentation references
The underlying Stateless library doesn't support async operations in callbacks by design. This creates confusion for developers expecting async/await to work everywhere. Our solution provides multiple layers of protection:
- Compile-time: Analyzers catch issues during development
- Runtime: Validation prevents incorrect usage
- Documentation: Clear guidance on correct patterns
- Thread-local storage tracks callback execution context
- Roslyn analyzers use syntax tree analysis for pattern detection
- Error messages include comprehensive context for debugging
No migration required. Version 1.0.2 is fully backward compatible with 1.0.x.
To benefit from the new analyzers:
- Update to Orleans.StateMachineES 1.0.2
- Rebuild your solution
- Address any new warnings/errors in your code
- Follow patterns in the Async Patterns Guide
Special thanks to our users who provided detailed feedback about async operation challenges. Your input directly shaped these improvements.
- Analyzers Added: 2
- Documentation Pages: 1 comprehensive guide
- Error Messages Enhanced: 3 categories
- Test Coverage: Maintained at 98%
Full Changelog: https://github.com/mivertowski/Orleans.StateMachineES/compare/v1.0.1...v1.0.2