TedToolkit.RoslynHelper
2026.4.14.1
dotnet add package TedToolkit.RoslynHelper --version 2026.4.14.1
NuGet\Install-Package TedToolkit.RoslynHelper -Version 2026.4.14.1
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="TedToolkit.RoslynHelper" Version="2026.4.14.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TedToolkit.RoslynHelper" Version="2026.4.14.1" />
<PackageReference Include="TedToolkit.RoslynHelper" />
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 TedToolkit.RoslynHelper --version 2026.4.14.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TedToolkit.RoslynHelper, 2026.4.14.1"
#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 TedToolkit.RoslynHelper@2026.4.14.1
#: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=TedToolkit.RoslynHelper&version=2026.4.14.1
#tool nuget:?package=TedToolkit.RoslynHelper&version=2026.4.14.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TedToolkit.RoslynHelper
A fluent API library for programmatically generating C# source code, designed for use in Roslyn incremental source generators and analyzers.
Features
- Fluent, chainable API to build classes, structs, records, interfaces, enums, delegates, and more
- Full C# member support: methods, properties, fields, events, constructors, indexers, operators, conversions
- Expression and statement builders (if, foreach, switch, try-catch, using, return)
- XML documentation comment generation (summary, param, returns, remarks, etc.)
- Generics, nullable types, pointers, ref/scoped parameters, nested types
- High-performance string building via ZString
- Targets
netstandard2.0- distributable as an analyzer component in NuGet packages - Automatic
GeneratedCodeAttributetracking
Installation
<ItemGroup>
<PackageReference Include="TedToolkit.RoslynHelper" Version="1.0.0" />
</ItemGroup>
Quick Start
using TedToolkit.RoslynHelper.Generators;
using TedToolkit.RoslynHelper.Generators.Syntaxes;
using static SourceComposer;
using static SourceComposer<MyGenerator>;
var code = File()
.AddNameSpace(NameSpace("MyApp.Models")
.AddMember(Class("Person").Public.Partial
.AddMember(Property<string>("Name").Public
.AddAccessor(Accessor(AccessorType.GET))
.AddAccessor(Accessor(AccessorType.SET)))
.AddMember(Method("Greet", ReturnType(DataType.String)).Public
.AddStatement("$\"Hello, I'm {Name}\"".ToSimpleName().Return))))
.ToCode();
Type Declarations
Class("MyClass").Public.Static.Unsafe.Partial
Struct("MyStruct").Public.Readonly
Record("MyRecord").Public
Interface("IMyInterface").Public
// With base types and generic constraints
Class("MyList").Public
.AddBaseType<IDisposable>()
.AddTypeParameter(TypeParameter("T").In
.AddNewConstraint()
.AddConstraint<IComparable>())
Members
// Method with parameters
Method("Calculate", ReturnType(DataType.Int)).Public
.AddParameter(Parameter<int>("x"))
.AddParameter(Parameter<int>("y"))
// Property with default value
Property<long>("Count").Internal
.AddAccessor(Accessor(AccessorType.GET))
.AddDefault(10.ToLiteral())
// Field, event, delegate
Field<long>("_count").Private.Readonly
Event<Action<int>>("ItemChanged").Public
Delegate("MyCallback").Public
// Enum
Enum("Status").Public
.AddEnumMember(EnumMember("Active"))
.AddEnumMember(EnumMember("Inactive"))
XML Documentation
Class("MyClass").Public
.AddRootDescription(new DescriptionSummary(
new DescriptionText("This is my class.")))
Dependencies
| Package | Version | Purpose |
|---|---|---|
| Microsoft.CodeAnalysis.CSharp | 5.0.0 | Roslyn compiler APIs |
| ZString | 2.6.0 | High-performance string building |
| System.Memory | 4.6.3 | Span/ReadOnlySpan support |
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- System.Memory (>= 4.6.3)
- ZString (>= 2.6.0)
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 |
|---|---|---|
| 2026.4.14.1 | 38 | 4/14/2026 |
| 2026.4.14 | 33 | 4/14/2026 |
| 2026.4.8 | 85 | 4/8/2026 |
| 2026.3.31 | 109 | 3/31/2026 |
| 2026.3.30.2 | 85 | 3/30/2026 |
| 2026.3.30.1 | 83 | 3/30/2026 |
| 2026.3.30 | 81 | 3/30/2026 |
| 2026.3.20 | 87 | 3/20/2026 |
| 2026.2.6.3 | 108 | 2/6/2026 |
| 2026.2.6.2 | 100 | 2/6/2026 |
| 2026.2.6.1 | 102 | 2/6/2026 |
| 2026.2.6 | 99 | 2/6/2026 |
| 2026.2.4.1 | 101 | 2/4/2026 |
| 2026.2.4 | 92 | 2/4/2026 |
| 2026.2.3 | 99 | 2/3/2026 |
| 2026.2.2 | 100 | 2/2/2026 |
| 2026.2.1.6 | 139 | 2/1/2026 |
| 2026.2.1.5 | 121 | 2/1/2026 |
| 2026.2.1.4 | 107 | 2/1/2026 |
| 2026.2.1.3 | 93 | 2/1/2026 |
Loading failed