Datacute.IncrementalGeneratorExtensions 1.0.6

dotnet add package Datacute.IncrementalGeneratorExtensions --version 1.0.6
                    
NuGet\Install-Package Datacute.IncrementalGeneratorExtensions -Version 1.0.6
                    
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="Datacute.IncrementalGeneratorExtensions" Version="1.0.6">
  <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="Datacute.IncrementalGeneratorExtensions" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Datacute.IncrementalGeneratorExtensions">
  <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 Datacute.IncrementalGeneratorExtensions --version 1.0.6
                    
#r "nuget: Datacute.IncrementalGeneratorExtensions, 1.0.6"
                    
#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 Datacute.IncrementalGeneratorExtensions@1.0.6
                    
#: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=Datacute.IncrementalGeneratorExtensions&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Datacute.IncrementalGeneratorExtensions&version=1.0.6
                    
Install as a Cake Tool

Fast-start helper set for building .NET incremental source generators: drop-in source files (added to your compilation) that cover attribute data collection, value-equality wrappers, structured emission, indentation, and lightweight tracing.

Features

  • SourceTextGenerator base class
  • EquatableImmutableArray
  • Attribute Context and Data (with TypeContext)
  • IndentingLineAppender (and tab variant)
  • LightweightTrace & GeneratorStage enum

More details, examples and exclusion symbols: https://github.com/datacute/IncrementalGeneratorExtensions

Quick Example (minimal, trimmed)

[Generator]
public sealed class DemoGenerator : IIncrementalGenerator
{
  public void Initialize(IncrementalGeneratorInitializationContext context)
  {
    var usages = context.SelectAttributeContexts(
      "MyNamespace.GenerateSomethingAttribute", 
      GenerateSomethingData.Collect);

    context.RegisterSourceOutput(usages, static (spc, usage) =>
    {
      var gen = new GenerateSomethingSource(in usage, in spc.CancellationToken);
      spc.AddSource(usage.CreateHintName("GenerateSomething"), gen.GetSourceText());
    });
  }
}

With a simple attribute:

[AttributeUsage(AttributeTargets.Class)]
public sealed class GenerateSomethingAttribute : Attribute
{
  public GenerateSomethingAttribute(string name) => Name = name;
  public string Name { get; }
}

Collecting attribute constructor arguments:

sealed class GenerateSomethingData : IEquatable<GenerateSomethingData>
{
  public GenerateSomethingData(string name) => Name = name;
  public string Name { get; }

  // Equals and GetHashCode not shown to keep the example brief

  public static GenerateSomethingData Collect(GeneratorAttributeSyntaxContext c)
    => new GenerateSomethingData((string)c.Attributes[0].ConstructorArguments[0].Value);
}

Using the simplest source generator:

sealed class GenerateSomethingSource : SourceTextGeneratorBase<GenerateSomethingData>
{
  readonly GenerateSomethingData _data;

  public GenerateSomethingSource(
    in AttributeContextAndData<GenerateSomethingData> usage, 
    in CancellationToken token)
    : base(in usage, in token) => _data = usage.AttributeData;

  protected override void AppendCustomMembers()
    => Buffer.AppendLine($"public static string GeneratedName => \"{_data.Name}\";");
}
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
1.0.6 62 8/16/2025
1.0.5 80 8/3/2025
1.0.4 62 8/3/2025
1.0.3 99 7/28/2025
1.0.2 72 7/27/2025