Skip to content

Getting Started

You can install the project from NuGet:

Terminal window
dotnet add package Hertzole.SourceGenUtils

Or as a package reference:

Project.csproj
<PackageReference Include="Hertzole.SourceGenUtils" Version="*" />

All generated types live in the Hertzole.SourceGen namespace.

Example.cs
using Hertzole.SourceGen;
using var writer = new CodeWriter();
writer
.AppendNamespace("MyApp.Models")
.AppendLine("public class User");
using (writer.WithBlock())
{
writer.AppendLine("public string Name { get; set; }");
}
Console.WriteLine(writer.ToString());

Dispose CodeWriter (and pools/scopes) to return buffers. See the API reference for details.