Concordia.Generator 1.0.1

dotnet add package Concordia.Generator --version 1.0.1
                    
NuGet\Install-Package Concordia.Generator -Version 1.0.1
                    
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="Concordia.Generator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Concordia.Generator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Concordia.Generator" />
                    
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 Concordia.Generator --version 1.0.1
                    
#r "nuget: Concordia.Generator, 1.0.1"
                    
#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 Concordia.Generator@1.0.1
                    
#: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=Concordia.Generator&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Concordia.Generator&version=1.0.1
                    
Install as a Cake Tool

Concordia.Generator: Compile-Time Handler Registration for Concordia

Concordia.Generator is the C# Source Generator component of the Concordia library. It automates the registration of your request handlers, notification handlers, pre-processors, post-processors, and pipeline behaviors at compile-time, eliminating the need for runtime reflection and significantly improving application startup performance.

Why Concordia?

  • An Open-Source Alternative: Concordia was created as an open-source alternative in response to other popular mediator libraries (like MediatR) transitioning to a paid licensing model. We believe core architectural patterns should remain freely accessible to the developer community.
  • Lightweight and Minimal: Provides only the essential Mediator pattern functionalities, without unnecessary overhead.
  • Optimized Performance: Thanks to Source Generators, handler discovery and registration happen entirely at compile-time, ensuring faster application startup and zero runtime reflection.
  • Easy DI Integration: Integrates seamlessly with Microsoft.Extensions.DependencyInjection.
  • Same MediatR Interfaces: Uses interfaces with identical signatures to MediatR, making migration or parallel adoption extremely straightforward.
  • CQRS and Pub/Sub Patterns: Facilitates the implementation of Command Query Responsibility Segregation (CQRS) and Publisher/Subscriber principles, enhancing separation of concern and code maintainability.

Key Features

  • Automatic Handler Registration: Scans your assemblies at compile-time to find and register IRequestHandler, INotificationHandler, IPipelineBehavior, IRequestPreProcessor, and IRequestPostProcessor implementations.
  • Zero Runtime Reflection: All service registration code is generated as C# source files, which are then compiled directly into your assembly.
  • Configurable Namespace and Method Names: Control the generated class's namespace and the DI extension method's name via MSBuild properties in your .csproj file.

Installation

Install Concordia.Core and Concordia.Generator in your application project:

dotnet add package Concordia.Core --version 1.0.0
dotnet add package Concordia.Generator --version 1.0.0

Usage

  1. Define your Handlers, Processors, and Behaviors (as described in Concordia.Core's documentation).

  2. Configure your .csproj: Add the Concordia.Generator as a ProjectReference with specific attributes and optionally configure the generated method name and namespace.

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
    
        <ConcordiaGeneratedMethodName>AddMyCustomMediatorHandlers</ConcordiaGeneratedMethodName>
    
    
      </PropertyGroup>
    
      <ItemGroup>
        <ProjectReference Include="PathToYour\Concordia.Core\Concordia.Core.csproj" />
        <ProjectReference Include="PathToYour\Concordia.Generator\Concordia.Generator.csproj"
                          OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
      </ItemGroup>
    </Project>
    
  3. Register services in Program.cs:

    using Concordia; // Required for IMediator, ISender
    using Concordia.DependencyInjection; // For AddConcordiaCoreServices
    using MyProject.Web; // Example: Namespace where ConcordiaGeneratedRegistrations is generated
    
    var builder = WebApplication.CreateBuilder(args);
    
    // 1. Register Concordia's core services.
    builder.Services.AddConcordiaCoreServices();
    
    // 2. Register your specific handlers and pipeline behaviors discovered by the generator.
    // The method name will depend on your .csproj configuration (e.g., AddMyCustomMediatorHandlers).
    builder.Services.AddMyCustomMediatorHandlers(); // Use the name configured in .csproj
    
    builder.Services.AddControllers();
    var app = builder.Build();
    app.MapControllers();
    app.Run();
    

The Source Generator will automatically find your handler implementations and generate a static class (e.g., ConcordiaGeneratedRegistrations) containing an extension method (e.g., AddMyCustomMediatorHandlers) that registers all your services with the DI container.

Contribution

Feel free to contribute to the project! Report bugs, suggest new features, or submit pull requests.

License

This project is released under the [Insert your license here, e.g., MIT License].

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 83 7/30/2025
1.0.0 86 7/30/2025