A high-performance source text writer for .NET incremental source generators using string interpolations
$ dotnet add package Raiqub.Generators.InterpolationCodeWriterA high-performance source text writer for .NET incremental source generators. Write generated source code using plain strings or C# string interpolations with automatic indentation support.
dotnet add package Raiqub.Generators.InterpolationCodeWriter
var writer = new SourceTextWriter();
writer.WriteLine("using System;");
writer.WriteLine();
writer.WriteLine($"namespace {ns};");
writer.WriteLine();
writer.WriteLine($"public class {className}");
writer.WriteLine("{");
writer.PushIndent();
writer.WriteLine($"public string Name {{ get; set; }}");
writer.PopIndent();
writer.WriteLine("}");
string result = writer.ToString();
PushIndent() / PopIndent() to manage indentation levels (4 spaces per level by default)$"..." syntax directlyInvariantCulture by defaultTargets .NET Standard 2.0, .NET 8, and .NET 10.
For the full documentation and guides, see the project repository.
See the LICENSE file for details.