Skip to content

A list of C# Source Generators (not necessarily awesome) and associated resources: articles, talks, demos.


Notifications You must be signed in to change notification settings


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation

C# Source Generators

A list of C# Source Generators (not necessarily awesome), because I haven't found a good list yet.

C# Source Generators is a Roslyn compiler feature introduced in C#9/.NET 5. It lets C# developers inspect user code and generate new C# source files that can be added to a compilation.

Add GitHub topic csharp-sourcegenerator to your generator repo - let's get it started!

Documentation and samples

Source Generators


Dependency Injection (IoC Container)

  • AutoCtor - stars last commit AutoCtor is a Roslyn Source Generator that will automatically create a constructor for your class for use with constructor Dependency Injection.
  • AutoRegisterInject - stars last commit Automatically generate Microsoft Dependency Injection ServiceCollection registrations for your classes from attributes.
  • DependencyInjection.SourceGenerators stars last commit This project is a C# source generator designed to simplify and automate the registration of dependencies in Microsoft's Dependency Injection service collection. By using this package, developers can enhance the clarity and efficiency of their code by reducing the need for manual service registration.
  • DependencyManagement - stars last commit The Dependency Management is a very fast dependency injection and components container, with many interesting features, and without reflection.
  • GrpcInjection -stars last commit - GrpcInjection is a tool that allow you to inject Services and Interceptor in time of compilation inside of GRPC Projects using C# source generator.
  • Injectio - stars last commit - Source generator that helps register discovered services in the dependency injection container
  • Jab -stars last commit - Compile Time Dependency Injection
  • lambdajection -stars last commit Framework for building AWS Lambdas using dependency injection and aspect-oriented programming.
  • MrMeeseeks.DIE - stars last commit An unambigous, convenient, flexible and feature rich compile time dependency injection container.
  • Pure.DI - stars last commit - dependency injection for .NET without any IoC/DI containers, frameworks, dependencies, and thus without any performance impact and side-effects.
  • SourceInject -stars last commit A source generator that allow you to generate your services for dependencies injection during compile time.
  • StrongInject -stars last commit - compile time dependency injection for .NET.
  • Thunderboltloc - stars last commit One of the very first IoC frameworks for .Net that has no reflection.

Console / CLI

  • AutoSpectre - stars last commit Generates a service for prompting and populating a class using the Spectre.Console library
  • - stars last commit generates C# source code that parses command-line arguments into a strong-typed arguments class (also generated), given just the POSIX-style usage in plain text as part of the CLI. In other words, write the help message for your program and get the entire parser generated for free!
  • Figgle - stars last commit - Generate ASCII banner text at compile time (or run time) using figlet fonts.


  • AutoDto -stars last commit - A source generator that generates DTO models from BL to avoid same BL and DTO models
  • Flattening - stars last commit - C# source generator for generating flattened classes from complex domain classes.
  • GraphQL.Tools -stars last commit - A GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
  • Mapperly -stars last commit - A source generator for generating object mappings. Inspired by MapStruct.
  • MappingCloningExtensions - stars last commit Generates extensions of objects for mapping and cloning using either attributes or fluent style. Also, supports deep copying and specfiying whether it can do a deep copy and the possibility of doing so safely.
  • Mapster -stars last commit - A fast, fun and performant object to object Mapper. Has better performance and is more memorry efficient than Automapper. Besides code generation, supports also Fluent API.
  • MapTo -stars last commit - A convention based object to object mapper similar to Automapper.
  • NextGenMapper - stars last commit Easy-to-use mapper without configuration.
  • SourceMapper - stars last commit - generates Mappers code based on attributes used on interfaces or abstract classes. It is inspired by Java MapStruct
  • SourceMapper -stars last commit A source generator that creates extension methods for cloning and mapping.


  • CoreWCF -stars last commit CoreWCF provides support of WCF server side code on .NET Core / .NET6. CoreWCF allows users to inject services into OperationContract implementation using a source generator to provide an OperationContract implementation that fits the expected ServiceContract. The supplied implementation fetch services from the DI container the same way the [FromServices] attribute works in ASP.NET core MVC Controllers. The source generator supports both a dedicated [Injected] attribute and the ASP.NET Core MVC [FromServices] attribute.
  • Imp.NET -stars last commit - a fast, high-level, object-oriented C# networking library that supports the invocation of remote methods through proxy interface objects.
  • IoTHubClientGenerator - stars last commit Build a C# Azure IoT Device client program in seconds!

Graphics / Drawing

  • ComputeSharp -stars last commit A .NET library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, which are transpiled from C# and precompiled at build-time using source generators.
  • Svg to C# Source Generators -stars last commit SVGC compiles SVG drawing markup to C# using SkiaSharp as rendering engine. SVGC can be also used as codegen for upcoming C# 9 Source Generator feature.


  • BetterEnums - stars last commit C# Enums with values and better performance as a source generator
  • Credfeto.Enumeration.Source.Generation -stars last commit Enum to text generator for enums - generates strongly typed enums for all enums in the assembly, and using EnumText attribute for third party enums. Also includes an analyzer to ensure that all enum usages use the .GetName extension method rather than .ToString.
  • Enum.Source.Generator - stars last commit A C# source generator to create an enumeration (enum) class from an enum type. With this package, you can work on enums very, very fast without using reflection.
  • EnumClass - stars last_commit Generate Kotlin's enum class from C# enum with additional features like Switch function (instead of switch statement). It also contains support libraries like generator for JsonConverter for generated classes
  • EnumerationClassGenerator -stars last commit - A C# source generator to create an enumeration class from an enum type.
  • EnumFastToStringDotNet -stars last commit - Automatically generates enum extension methods that implement a switch expression based ToString method.
  • EnumUtilitiesGenerator -stars last commit - A source generator to generate compile-time mapping of enums and description attributes.
  • FastEnumGenerator - stars last commit An enum like generator where you create a partial class with private enum and it will generate an enum like record struct even including returning the words and a list.
  • JOS.Enumeration - Enumeration class powered by source generation

Functional Programming

Value semantic / New Type Idiom

  • Generator.Equals - stars last commit generates equality and hashing for classes and records, supports a number of strategies for comparing collections and properties.
  • RSCG_UtilityTypes - stars last commit Add Omit and Pick attributes to generate classes from existing class, like in TypeScript.
  • Strongly stars last commit - Easily generate serializable domain value types
  • ValueObjectGenerator - stars last commit C# source generator is for ValueObjects (ie.Wrapper classes).
  • Vogen - stars last commit C# source generator and code analyser that generates strongly typed domain identities.
  • WrapperValueObject - stars last commit - for creating simple value objects wrapping primitive types.


Discriminated Unions

  • AnyOf - stars last commit The Source Generator creates a AnyOf<First, TSecond, ...> type to handle multiple defined types as input parameters for methods.
  • dotVariant - stars last commit A type-safe and space-efficient sum type for C# (comparable to discriminated unions in C or C++).
  • Dunet - stars last commit A simple source generator for discriminated unions in C#.
  • Funcky Discriminated Unions - stars last commit A source generator that generates Match methods for all your discriminated unions needs. ✨ Can be used with or without the functional programming library Funcky.
  • N.SourceGenerators.UnionTypes - stars last commit Discriminated union type source generator.
  • Unions - stars last commit for generating meaningful, efficient union types.


  • AutoDeconstructable -stars last commit Generator for efficient and automatic flat text serializer/deserializer using Deconstructable aspect in NTP library.
  • Azura -stars last commit Generates binary [de]serializers on Streams at design time.
  • CSV-Parser-Generator - stars last commit A Parser for CSV with support for uncommon line separators (e.g. Unicode) and instantiation of read-only objects and working nullable handling.
  • ProtobufSourceGenerator -stars last commit - A source generator that generates partial helper classes where member properties are attributed with ProtoMember attribute.
  • SerdeDn (serde-sn) -stars last commit is a port of the popular Rust serialization/deserialization library to .NET. Basic cases are fully automated using a C# source generator.
  • SpreadCheetah -stars last commit Create Excel files with a C# Source Generator for generating the rows.
  • StackXML -stars last commit Stack based zero-allocation XML serializer and deserializer.
  • StructPacker -stars last commit binary serializer that auto-generates C# serialization code to achieve peak runtime performance and efficiency.
  • Tinyhand -stars last commit - Tiny and simple data format/serializer using a source generator.


  • GeneratedJsonConverters -stars last commit - generate json converters for polymorph contracts and string based enum serialization.
  • JsonByExampleGenerator -stars last commit - generate classes based on example json files in your project.
  • JsonDeserializeResourceSourceGenerator - stars last commit Instead of having to do embedded resource, can instead have json as additional file and it will produce a c# string and will deserialize to a type specified.
  • JsonPolymorphicGenerator - stars last commit - Source Code Generator for System.Text.Json JsonDerivedType attributes on polymorphic classes
  • JsonSerializerContextGenerator - stars last commit A source generator that produces nearly the same code ahs system.json.text but easier to use because you only have to put an attribute for a model class you want to produce for. Also, produces a method to register to make it easy to use that source generator when serializing/deserializing json.
  • JsonSrcGen -stars last commit - compile time JSON serializer generation.
  • TeuJson - stars last commit A Reflection-less and Lightweight Json Library using source generator.


  • kli.Localize - stars last commit - localize strings from json files via source code generation
  • MrMeeseeks.ResXToViewModelGenerator - stars last commit Takes ResX files and generates localization ViewModels for a more convenient usage of localization in MVVM projects.
  • ResXGenerator -stars last commit Generates strongly-typed resource classes for looking up localized strings.


  • Buildenator -stars last commit Generate data builder classes for testing purposes (and not only) for your entities. Autofixture + Moq extensions.
  • FluentAssertions.Eventual - stars last commit - Generates a specialized waiting wrapper for FluentAssertions assertions, offering a syntax similar to plain FluentAssertions.
  • ScenarioTests -stars last commit Test your code like you would write a notebook. Simply and effective


  • GRPC-Mock-Server -stars last commit - A source generator for stubbing GRPC services.
  • InterfaceGenerator - stars last commit - Auto generate interface definition by implementation, for when you need an abstraction for the sake of mocking.
  • MockableStaticGenerator - stars last commit A C# source generator to make an interface and a class wrapper to test static/extension methods.
  • MockGen - stars last commit A C# mocking library based on source generators.
  • MockSourceGenerator - stars last commit A C# mocking library that generates mocks at compile-time using a source generator.
  • ProxyInterfaceGenerator -stars last commit generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI.
  • Rocks - stars last commit A mocking library based on the Compiler APIs (Roslyn + Mocks).


  • Lombok.NET - stars last commit Generates boilerplate code and common code patterns. As the name suggests, it is the .NET version of Java's Lombok.


  • DumplingsDevs.Pipelines - stars last commit The most flexible mediation implementation in the .NET ecosystem with your own types.
  • Immediate.Handlers -stars last commit An implementation of the Mediator pattern in .NET using source generators, without using a central mediator instance.
  • Mediator -stars last commit - a high performance implementation of Mediator pattern in .NET using source generators.
  • MediatR controllers generator -stars last commit This generator generates controllers and their methods based on your MediatR requests.


  • Plastic -stars last commit This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.


  • Data Builder Generator -stars last commit Generate data builder patterns for your model classes.
  • FluentBuilder - stars last commit - A project which uses Source Generation to create a FluentBuilder for a specified model or DTO.
  • M31.FluentAPI - stars last commit - Generate fluent APIs for your C# classes with ease.


  • avatar -stars last commit A modern compile-time generated interception/proxy library.
  • DudNet - stars last commit A C# source generator for implementing a proxy pattern.


  • MrMeeseeks.Visitor - stars last commit Generates the boilerplate code for applications of the Visitor pattern.


Domain Driven Design (DDD)

  • AltaSoft.DomainPrimitives - stars last commit - A C# toolkit purposefully designed to accelerate the development of domain-specific primitives within your applications. This streamlined solution empowers developers to efficiently encapsulate fundamental domain logic. Through this toolkit, you'll significantly reduce code complexity while improving the maintainability of your project.
  • Architect.DomainModeling - stars last commit A complete Domain-Driven Design (DDD) toolset for implementing domain models, including base types and source generators for ValueObjects, WrapperValueObjects, Entities, and Identities.


  • GenerateHelperLibraries - stars last commit A source generator where you can send any code to the client without having to do as a string. Helper for custom classes a client has to override in order to have additional features for source generators. Intended to be used from another source generator.
  • Gobie -stars last commit - Allows developers define and use custom source generation without writing any generator code themselves or learning the Roslyn APIs. Instead, devs define the generator they want, in C#, and can then use that generator throughout their project.
  • Matryoshki - stars last commit Metaprogramming framework based on C# source generators. It allows you to define behaviours with adornments and generate decorators for arbitrary types.
  • SourceGeneratorQuery - stars last commit - C# SourceGenerator helper which helps you query your files, and adds LINQ support.


  • AjaxService.Gen - stars last commit - Automatically Generate typescript Ajax calls based on your C# Api endpoints.
  • ApiClientGenerator - stars last commit Generates a strongly typed HttpClient based off MVC's default routing. Can be used to output into multiple projects, like Blazor WebAssembly.
  • ControllerGenerator -stars last commit Automatically generate controllers from services in a web application
  • HttpClientCodeGenerator -stars last commit - HttpClientGenerator is a tool that uses the Roslyn code generator feature to write boilerplate HttpClient code for you.
  • Ridge -stars last commit Generates strongly-typed clients for API based on controller definition and internal application details.
  • Safe-Routing -stars last commit Analyses a project's razor pages and MVC controllers, producing strongly-typed representations of those routes as you type
  • TypedSignalR.Client -stars last commit C# Source Generator to create strongly typed SignalR clients.

Open Api

  • H.NSwag.Generator -stars last commit - C# Source Generator for NSwag.
  • SourceApi - stars last commit - API first Open API code generator based on json or yaml definitions. It generates base abstract controllers with docs, routes, that you inherit and implement in your controllers.
  • ST.NSwag.ServerSourceGenerator -stars last commit Generates Web API/ASP.NET Core controllers from a OpenAPI specification.

Razor / Blazor

  • BlazorInteropGenerator -stars last commit Generates Blazor -> Javascript strongly typed interop methods, by parsing the Javascript it self and generating extension methods for IJSRuntime.
  • BlazorOcticons - stars last commit Github Octicons created as a .razor components using source generator. The generated components are available via the NuGet package, the generator itself is available as a separate NuGet package. The project website is an example using the generated components.
  • MiniRazor -stars last commit Portable Razor compiler & code generator.
  • RazorPageRouteGenerator - stars last commit Generates methods with parameters for Razor and Blazor pages, so you can navigate without having to guess URLs or parameters.

XAML / WPF / Avalonia


  • PropertyChanged.SourceGenerator -stars last commit - Powerful INotifyPropertyChanged Source Generator, which generates INPC boilerplate for you as part of your build. Supports features such as automatic and manual dependencies between properties, notifications when specific properties change, and more.
  • ValueChangedGenerator -stars last commit for generating PropertyChanged from inner struct members.

Model View Viewmodel (MVVM)

  • DevExpress.Mvvm.CodeGenerators - stars last commit Generates boilerplate code for your View Models (INotifyPropertyChanged, Commands, IDataErrorInfo, DevExpress services). Compatible with the Prism and MVVM Light libraries.
  • Microsoft MVVM Toolkit -stars last commit A modular MVVM library with support for source generators to reduce boilrplate and improve performance.
  • MvvmGen - stars last commit A lightweight MVVM library for XAML applications that generates your ViewModels with a C# Source Generator.

Database / ORM

  • AdaskoTheBeAsT.Identity.Dapper - stars last commit - Custom Dapper implementation for Microsoft.Extensions.Identity.Stores (part of ASP.NET Core Identity)
  • Breezy - stars last commit Micro ORM with source generator.
  • MapDataReader - stars last commit - Fast mapping IDataReader to a custom class
  • SqlMarshal -stars last commit Native AOT friendly-performant mini-ORM. Generation of wrappers for accessing SQL using ADO.NET.

Statically typed resources / configurations

  • dot-env-generator - stars last commit A source generator for C# that turns .env files into runtime constants.
  • EnvVariablesGenerator - stars last commit Generate code from .env files that can be changed after build.
  • NotNot.AppSettings - stars last commit Automatically create strongly typed C# settings objects from AppSettings.json.
  • SourceConfig - stars last commit - Generates configuration POCO objects, lists, dictionaries in AOT based on *.json config files.
  • StronglyTypedEmbeddedResources - stars last commit Generates strongly typed names for Embedded Resources automatically.
  • TxtToListGenerator - stars last commit A source generator where if you have a text file as additional file and you have a list ordered by return carriages, then it produces either a list of int or a list of string in c#.

Text templating

  • Transplator - stars last commit A simple C# source generator for text templates.
  • Weave - stars last commit Weave is a text templating engine for .NET that is all about attention to detail. Weave handles the tricky work of making your rendered text beautiful.


  • AutoConstructor - stars last commit C# source generator that generates a constructor from readonly fields/properties in a class or struct.
  • AutoFilterer.Generators - stars last commit AutoFilterer.Generators aims to generate filter DTOs from entities automatically via using dotnet source generators.
  • AutomaticInterface - stars last commit Generate an Interface from a class.
  • AutoInvoke -stars last commit A generator that generates a method that invokes a specified generic method, for every Type in your project that satisfies a defined constraint.
  • BigMachines -stars last commit BigMachines is State Machine library for .NET.
  • BitsKit - A C# library for efficient bit-level reading and writing also adding bit field support
  • CacheSourceGenerator -stars last commit Generates an IMemoryCache wrapper around a method call.
  • Cloneable -stars last commit auto-generate Clone method.
  • Durian - stars last commit Extends the default capabilities of C# by mimicking features from other languages.
  • Fairy -stars last commit generates C# code based on Sitecore Content Serialization (SCS) .yml files.
  • FastGenericNew - stars last commit The ultimate fast alternative to Activator.CreateInstance<T> / new T(). Built on SourceGenerator V2 (Incremental Generator).
  • GitBuildInfo.SourceGenerator -stars last commit - for dumping the git information (commit hash, branch, the head description) into assembly level metadata attributes.
  • Hangfire.RecurringJob - stars last commit - Automatically generates the recurring job registration code.
  • IDisposableGenerator -stars last commit - a Source Generator for Generating the Dispose functions in Disposables. All you have to do is mark them with attributes and it will work from there.
  • Lazysh - stars last commit Lazy implementation of any interface.
  • LinqGen - stars last commit Alloc-free and fast replacement for Linq, with code generation.
  • LoggingDecoratorGenerator - stars last commit Generates logger decorator class for an interface. Uses Microsoft.Extensions.Logging.ILogger to log and requires it in decorator class constructor.
  • MemberAccessGenerator -stars last commit generates GetMember(int) and/or GetMember(string) methods that return property value for a given property name or index (e.g. in positional records).
  • MrMeeseeks.StaticDelegateGenerator - stars