-
Notifications
You must be signed in to change notification settings - Fork 0
Target Framework Compatibility
FunctionalStateMachine.Core and FunctionalStateMachine.CommandRunner both multi-target so the correct build is selected automatically based on your project's target framework.
| Target framework | Gets |
|---|---|
netstandard2.0 |
Broadest compatibility — .NET Framework 4.6.1+, .NET Core 2.0+, Xamarin, Unity |
net8.0 |
AOT-compatible build with full trim analysis |
When you reference the NuGet package from a net8.0 or net9.0 project, NuGet automatically selects the net8.0 build. When you reference it from a netstandard2.0-compatible target, NuGet selects the netstandard2.0 build.
All state machine features are identical across both targets. The only difference is in the internals:
| Feature | netstandard2.0 |
net8.0+ |
|---|---|---|
| Full fluent API | ✅ | ✅ |
| Guards, conditionals | ✅ | ✅ |
| Hierarchical states | ✅ | ✅ |
Static analysis on .Build()
|
✅ | ✅ |
| Unused-trigger analysis | ✅ (when generator active) | ✅ (when generator active) |
| AOT / NativeAOT safe | netstandard2.0) |
✅ |
| Trim-safe | netstandard2.0) |
✅ |
[ModuleInitializer] for trigger registry |
✅ (when PolySharp present) | ✅ |
The source generator (FunctionalStateMachine.Core.Generator) is a netstandard2.0 Roslyn analyzer and works with all target frameworks. The generated [ModuleInitializer] code requires the System.Runtime.CompilerServices.ModuleInitializerAttribute type, which is:
- Available natively in
.NET 5and later - Back-ported to
netstandard2.0by PolySharp if you have it installed
If neither is available (e.g. plain netstandard2.0 without PolySharp), the generator silently skips generation and unused-trigger analysis is bypassed without error.
If your project targets .NET Framework, the netstandard2.0 build is used. The state machine works fully, but:
- Unused-trigger analysis will not report warnings (no
[ModuleInitializer]support without PolySharp) - AOT and trim tooling are not applicable