🎯 Atc Source Generators

March 13, 2026 Β· View on GitHub

A collection of Roslyn C# source generators for .NET that eliminate boilerplate code and improve developer productivity. All generators are designed with Native AOT compatibility in focus, enabling faster startup times, smaller deployment sizes, and optimal performance for modern cloud-native applications.

Why Choose Atc Source Generators?

  • 🎯 Zero boilerplate - Attribute-based approach eliminates repetitive code
  • ⚑ Compile-time generation - Catch errors during build, not at runtime
  • πŸš€ Native AOT ready - Zero reflection, fully trimming-safe for modern .NET
  • 🧩 Multi-project architecture - Smart naming for clean layered applications
  • πŸ›‘οΈ Type-safe - Full IntelliSense and compile-time validation
  • πŸ“¦ Single package - Install once, use all generators

πŸš€ Source Generators

GeneratorAttributeWhat It Does
⚑ DependencyRegistration[Registration]Automatic DI service registration with auto-detection, keyed services, factories, decorators
βš™οΈ OptionsBinding[OptionsBinding]Configuration binding with validation, change callbacks, named options
πŸ—ΊοΈ ObjectMapping[MapTo(typeof(T))]Object-to-object mapping with bidirectional, nested, and collection support
πŸ”„ EnumMapping[MapTo(typeof(T))]Enum-to-enum mapping with special case detection (None ↔ Unknown)
πŸ“‹ AnnotationConstants(automatic)Compile-time access to DataAnnotation metadata without reflection

✨ See It In Action

All generators work together seamlessly in a typical 3-layer architecture:

// 1️⃣ Domain Layer - Your business logic
[MapTo(typeof(PetStatusDto), Bidirectional = true)]
public enum PetStatus { Available, Adopted }

[MapTo(typeof(PetDto))]
public partial class Pet
{
    public Guid Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public PetStatus Status { get; set; }
}

[Registration(Lifetime.Scoped)]
public class PetService : IPetService
{
    public async Task<Pet> GetPetAsync(Guid id) { /* ... */ }
}

[OptionsBinding("PetStore")]
public partial class PetStoreOptions
{
    [Required] public int MaxPetsPerPage { get; set; }
}

// 2️⃣ Program.cs - One line per concern
using Atc.DependencyInjection;
using Atc.Mapping;

builder.Services.AddDependencyRegistrationsFromDomain();
builder.Services.AddOptionsFromDomain(builder.Configuration);

// 3️⃣ Usage - Clean and type-safe
app.MapGet("/pets/{id}", async (Guid id, IPetService service) =>
{
    var pet = await service.GetPetAsync(id);
    return Results.Ok(pet.MapToPetDto());  // ✨ Generated mapping
});

Result: Zero boilerplate, full type safety, Native AOT ready! πŸš€

πŸ“¦ Installation

dotnet add package Atc.SourceGenerators

Optional (recommended for better IntelliSense):

dotnet add package Atc.SourceGenerators.Annotations

βš™οΈ Requirements

  • .NET 10 SDK required at build time (Roslyn 5.0.0)
  • Projects can still target .NET 9, .NET 8, or earlier
  • This is a build-time requirement only, not a runtime requirement

πŸ“– Documentation

Full documentation is available in the Wiki:

PageDescription
Getting StartedInstallation, packages, and SDK requirements
Dependency RegistrationAutomatic DI with [Registration] β€” auto-detection, keyed services, factories, decorators, transitive registration
Options BindingConfiguration binding with [OptionsBinding] β€” validation, change callbacks, named options, child sections
Object MappingObject mapping with [MapTo] β€” bidirectional, nested objects, collections, projections, property strategies
Enum MappingEnum mapping with [MapTo] β€” special case detection, bidirectional, case-insensitive
Annotation ConstantsCompile-time DataAnnotation metadata β€” zero reflection, Blazor-ready, Native AOT
Sample ProjectsWorking code examples for each generator
PetStore API ExampleFull application using all generators with OpenAPI/Scalar

πŸ”¨ Building

dotnet build

πŸ§ͺ Testing

dotnet test

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

[License information here]