NickSoftware.Switchboard.SourceGenerators 0.1.0-preview.52

This is a prerelease version of NickSoftware.Switchboard.SourceGenerators.
This package has a SemVer 2.0.0 package version: 0.1.0-preview.52+f70eb54.
dotnet add package NickSoftware.Switchboard.SourceGenerators --version 0.1.0-preview.52
                    
NuGet\Install-Package NickSoftware.Switchboard.SourceGenerators -Version 0.1.0-preview.52
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NickSoftware.Switchboard.SourceGenerators" Version="0.1.0-preview.52">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NickSoftware.Switchboard.SourceGenerators" Version="0.1.0-preview.52" />
                    
Directory.Packages.props
<PackageReference Include="NickSoftware.Switchboard.SourceGenerators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NickSoftware.Switchboard.SourceGenerators --version 0.1.0-preview.52
                    
#r "nuget: NickSoftware.Switchboard.SourceGenerators, 0.1.0-preview.52"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NickSoftware.Switchboard.SourceGenerators@0.1.0-preview.52
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NickSoftware.Switchboard.SourceGenerators&version=0.1.0-preview.52&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NickSoftware.Switchboard.SourceGenerators&version=0.1.0-preview.52&prerelease
                    
Install as a Cake Tool

Switchboard Source Generators

Roslyn source generators for the Switchboard Amazon Connect framework. Automatically generates FlowBuilder extension methods from attribute-decorated classes.

NuGet

⚠️ 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

Documentation


Part of the Switchboard framework for Amazon Connect

There are no supported framework assets in this package.

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/