Skip to content

Installation

  • .NET 10 SDK or later
  • An IDE with C# support (VS 2022, Rider, VS Code)

Start with the modules you need:

Terminal window
# Core (always needed)
dotnet add package Pragmatic.Result
dotnet add package Pragmatic.Ensure
# Pick what you need
dotnet add package Pragmatic.Endpoints
dotnet add package Pragmatic.Actions
dotnet add package Pragmatic.Persistence.EFCore
dotnet add package Pragmatic.Validation
dotnet add package Pragmatic.Mapping
<ProjectReference Include="path/to/Pragmatic.SourceGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />

Or via NuGet (when published):

Terminal window
dotnet add package Pragmatic.SourceGenerator
Terminal window
dotnet build

The Source Generator automatically detects which Pragmatic modules are referenced and generates the appropriate code. No configuration needed.

The generator scans your referenced assemblies and produces code based on what it finds:

If you reference…The generator produces…
Pragmatic.EndpointsEndpoint registration, request binding
Pragmatic.ActionsAction invokers, DI wiring
Pragmatic.Persistence.EFCoreRepositories, entity configs, query filters
Pragmatic.ValidationValidator registration
Pragmatic.MappingMapping extension methods
Pragmatic.CompositionStartup step orchestration

After building, check the obj/ folder for generated files:

obj/Debug/net10.0/generated/
└── Pragmatic.SourceGenerator/
├── PlaceOrder.Invoker.g.cs
├── GetProductEndpoint.Handler.g.cs
└── ...