NickSoftware.Switchboard.SourceGenerators
0.1.0-preview.52
dotnet add package NickSoftware.Switchboard.SourceGenerators --version 0.1.0-preview.52
NuGet\Install-Package NickSoftware.Switchboard.SourceGenerators -Version 0.1.0-preview.52
<PackageReference Include="NickSoftware.Switchboard.SourceGenerators" Version="0.1.0-preview.52"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="NickSoftware.Switchboard.SourceGenerators" Version="0.1.0-preview.52" />
<PackageReference Include="NickSoftware.Switchboard.SourceGenerators"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add NickSoftware.Switchboard.SourceGenerators --version 0.1.0-preview.52
#r "nuget: NickSoftware.Switchboard.SourceGenerators, 0.1.0-preview.52"
#:package NickSoftware.Switchboard.SourceGenerators@0.1.0-preview.52
#addin nuget:?package=NickSoftware.Switchboard.SourceGenerators&version=0.1.0-preview.52&prerelease
#tool nuget:?package=NickSoftware.Switchboard.SourceGenerators&version=0.1.0-preview.52&prerelease
Switchboard Source Generators
Roslyn source generators for the Switchboard Amazon Connect framework. Automatically generates FlowBuilder extension methods from attribute-decorated classes.
⚠️ PREVIEW RELEASE: Part of the Switchboard preview release. APIs may change.
Overview
This package provides Roslyn source generators that enable attribute-based flow definitions. Define your custom flow actions using attributes, and the generators create strongly-typed FlowBuilder extension methods automatically.
Features
- Zero Runtime Overhead - Code generated at compile time
- Full IntelliSense - Generated methods appear in IDE autocomplete
- Type-Safe Parameters - Strong typing for all action parameters
- Custom Transitions - Define custom branching logic
Installation
dotnet add package NickSoftware.Switchboard.SourceGenerators --prerelease
This package is typically installed alongside the main Switchboard package:
dotnet add package NickSoftware.Switchboard --prerelease
dotnet add package NickSoftware.Switchboard.SourceGenerators --prerelease
Usage
Define a Custom Flow Action
using Switchboard.SourceGenerators.Attributes;
[FlowAction("VerifyCustomer", Description = "Verifies customer identity")]
public class VerifyCustomerAction
{
[Parameter("AccountNumber", Required = true)]
public string AccountNumber { get; set; } = "";
[Parameter("VerificationType")]
public string VerificationType { get; set; } = "PIN";
[Transition("Verified")]
public string OnVerified { get; set; } = "";
[Transition("Failed")]
public string OnFailed { get; set; } = "";
[Transition("Error")]
public string OnError { get; set; } = "";
}
Use the Generated Extension Method
var flow = new FlowBuilder()
.SetName("CustomerVerificationFlow")
.PlayPrompt("Please enter your account number")
.VerifyCustomer(action =>
{
action.AccountNumber = "$.StoredCustomerInput";
action.VerificationType = "PIN";
})
.OnVerified(b => b.TransferToQueue("Support"))
.OnFailed(b => b.PlayPrompt("Verification failed").Disconnect())
.OnError(b => b.PlayPrompt("An error occurred").Disconnect())
.Build();
Attributes
[FlowAction]
Marks a class as a flow action definition.
[FlowAction("ActionName", Description = "Optional description")]
public class MyAction { }
[Parameter]
Defines an action parameter.
[Parameter("ParameterName", Required = true, DefaultValue = "default")]
public string MyParameter { get; set; }
[Transition]
Defines a transition/branch from the action.
[Transition("TransitionName")]
public string OnTransition { get; set; }
Generated Code
The source generator creates extension methods like:
// Generated code
public static IVerifyCustomerBuilder VerifyCustomer(
this IFlowBuilder builder,
Action<VerifyCustomerAction>? configure = null)
{
// Implementation generated automatically
}
public interface IVerifyCustomerBuilder : IFlowBuilder
{
IFlowBuilder OnVerified(Action<IFlowBuilder> configure);
IFlowBuilder OnFailed(Action<IFlowBuilder> configure);
IFlowBuilder OnError(Action<IFlowBuilder> configure);
}
Viewing Generated Code
In Visual Studio, you can view generated code under:
- Dependencies → Analyzers → NickSoftware.Switchboard.SourceGenerators
Or enable source file output in your project:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
Requirements
- .NET Standard 2.0 compatible
- Works with .NET 6.0+ projects
Related Packages
- NickSoftware.Switchboard - Core framework
- NickSoftware.Switchboard.Analyzers - Compile-time validation
Documentation
Part of the Switchboard framework for Amazon Connect
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.52 | 47 | 12/3/2025 |
| 0.1.0-preview.51 | 32 | 12/2/2025 |
| 0.1.0-preview.48 | 39 | 12/2/2025 |
| 0.1.0-preview.47 | 26 | 12/1/2025 |
| 0.1.0-preview.46 | 40 | 12/1/2025 |
| 0.1.0-preview.45 | 47 | 11/30/2025 |
| 0.1.0-preview.44 | 39 | 11/30/2025 |
| 0.1.0-preview.43 | 38 | 11/30/2025 |
| 0.1.0-preview.42 | 46 | 11/30/2025 |
| 0.1.0-preview.41 | 38 | 11/30/2025 |
| 0.1.0-preview.39 | 40 | 11/30/2025 |
| 0.1.0-preview.38 | 38 | 11/29/2025 |
| 0.1.0-preview.37 | 43 | 11/29/2025 |
| 0.1.0-preview.36 | 45 | 11/28/2025 |
| 0.1.0-preview.35 | 50 | 11/27/2025 |
| 0.1.0-preview.34 | 48 | 11/27/2025 |
| 0.1.0-preview.32 | 47 | 11/27/2025 |
| 0.1.0-preview.31 | 44 | 11/27/2025 |
| 0.1.0-preview.29 | 56 | 11/26/2025 |
| 0.1.0-preview.26 | 51 | 11/25/2025 |
| 0.1.0-preview.16 | 104 | 10/26/2025 |
Preview release - APIs may change. See documentation at https://nicksoftware.github.io/switchboard-docs/