Roslyn Analyzers
ALPHA
The analyzer package is currently in alpha. Rule behavior and IDs may change between releases.
Switchboard provides optional Roslyn analyzers that catch common semantic mistakes in the fluent FlowBuilder DSL. These are the kinds of issues that compile fine, but would otherwise produce surprising flow behavior at runtime.
Installation
Install the analyzer package into the project(s) where you build flows:
dotnet add package NickSoftware.Switchboard.AnalyzersThis package is separate from the main Switchboard runtime package.
What It Checks
The analyzers currently focus on two big categories:
- Flow builder basics (e.g., empty flows, missing name, missing terminal action)
- Builder-returning blocks that require branch configuration, such as:
Loop(..., loop => ...)Wait(..., wait => ...)DistributeByPercentage(dist => ...)CheckHoursOfOperation(...),CheckStaffing*,CheckQueueStatus*,CheckCallProgress(...)
For the complete rule list and examples, see Reference: Analyzers.
Code Fixes
Some diagnostics include Quick Actions. For example, SWB002 can offer a fix to insert .Disconnect() before .Build().
Configuration
You can control severity via .editorconfig:
[*.cs]
# Examples
dotnet_diagnostic.SWB002.severity = error
dotnet_diagnostic.SWB011.severity = warning
dotnet_diagnostic.SWB017.severity = noneOr suppress a diagnostic in code:
#pragma warning disable SWB002
var flow = Flow.Create("Example")
.SetName("NoTerminal")
.PlayPrompt("Hello")
.Build();
#pragma warning restore SWB002Known Limitations
- Rules that inspect
configurelambdas (e.g.,Loop(..., loop => ...)) intentionally analyze inline lambdas only. - Some branch-builder rules apply within a single fluent expression (they don’t trace configuration split across multiple statements).
Next Steps
- Reference: Analyzers - Complete rule reference
- Source Generators - Code generation
- Flow Validation - All validation layers