Franz.Common.Mediator.SourceGenerator 3.0.0

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

Franz.Common.Mediator.SourceGenerator

Incremental Roslyn generator for compile-time Mediator handler registration, typed dispatch invokers, messaging manifests, and dispatch-call diagnostics.

Overview

The generator runs in each application compilation that references Franz.Common.Mediator. It discovers supported handler contracts in that compilation and emits an assembly-scoped registration contribution. It is included in the Mediator package analyzer assets; applications should normally reference Franz.Common.Mediator, not this generator package directly.

Installation

dotnet add package Franz.Common.Mediator.SourceGenerator

Most applications should reference Franz.Common.Mediator, which already includes the generator as an analyzer asset. Install this package directly only when the analyzer itself is the intended dependency.

Compatibility

  • Targets .NET Standard 2.0.
  • Uses Microsoft.CodeAnalysis 5.6.
  • Package version follows the Franz.Common release version defined in common.targets.

Generated registration

The generator discovers implementations of:

  • ICommandHandler<TCommand, TResult>
  • ICommandHandler<TCommand>
  • IQueryHandler<TQuery, TResult>
  • INotificationHandler<TNotification>
  • IEventHandler<TEvent>
  • IStreamQueryHandler<TQuery, TResult>
  • Supported IValidator<TRequest> contracts

It emits a module-initialized contribution for the containing assembly. The contribution registers handlers with DI, emits typed command/query/void-command invokers and event publisher invokers, and creates typed pre/post-processor invokers for discovered request contracts. Stream-query and notification handlers are registered for direct DI resolution.

The generator also emits a closed-generic default-pipeline contribution for supported request and notification contracts. AddFranzMediatorDefault<TAssemblyMarker>() applies that contribution. The generated pipeline contribution is distinct from the open-generic pipeline registrations used by the V2 default and standard bootstrap helpers.

Messaging manifest

When the messaging manifest contracts are present in the compilation, the generator emits an assembly contribution to MessagingManifestRegistry. The manifest records integration-event types and their discovered handler/subscription relationships. Event-based Kafka registration consumes this generated manifest to validate topic subscriptions; the generator does not create broker topics itself.

Diagnostic FRZMED001

The generator emits warning FRZMED001 when a statically typed call through IDispatcher.SendAsync, PublishNotificationAsync, or PublishEventAsync uses a concrete request/event type for which the current compilation contains no matching generated handler registration.

The diagnostic intentionally skips calls whose request type is an interface, abstract type, or generic type parameter because the concrete runtime type cannot be established reliably at compile time. The diagnostic is scoped to the current compilation; it cannot see handler registrations generated by a different assembly.

This is a compile-time warning, not a universal runtime fail-fast guarantee. Missing command, void-command, and query invokers are rejected by the generated invoker registry. Notification and generic event dispatch resolve handler collections through DI and may complete without invoking a handler when no matching registration exists. Keep integration tests for cross-assembly composition and message contracts.

Registration boundary

Use the Mediator registration API with the assembly that contains the handlers:

  • AddFranzMediator(assemblies) for the V1 generated registration provider.
  • AddFranzMediatorV2(handlerAssembly: ...) for the V2 generated registration provider.
  • AddFranzMediatorDefault<TAssemblyMarker>() when applying generated closed-generic default pipelines.

The generator contributes registrations for the assembly being compiled. Selecting another assembly does not cause the generator to inspect that assembly at runtime.

License

MIT. See the repository 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
3.0.0 43 11/10/2026
2.3.4 815 11/1/2026
2.3.3 683 10/28/2026
2.3.2 493 10/27/2026
2.3.1 551 10/26/2026
1.0.0 736 7/21/2026