REslava.Result.SourceGenerators 1.35.0

Prefix Reserved
dotnet add package REslava.Result.SourceGenerators --version 1.35.0
                    
NuGet\Install-Package REslava.Result.SourceGenerators -Version 1.35.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="REslava.Result.SourceGenerators" Version="1.35.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="REslava.Result.SourceGenerators" Version="1.35.0" />
                    
Directory.Packages.props
<PackageReference Include="REslava.Result.SourceGenerators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 REslava.Result.SourceGenerators --version 1.35.0
                    
#r "nuget: REslava.Result.SourceGenerators, 1.35.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 REslava.Result.SourceGenerators@1.35.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=REslava.Result.SourceGenerators&version=1.35.0
                    
Install as a Cake Addin
#tool nuget:?package=REslava.Result.SourceGenerators&version=1.35.0
                    
Install as a Cake Tool

REslava.Result.SourceGenerators

Zero-boilerplate ASP.NET endpoint generation — write business logic, Minimal API + MVC endpoints generate themselves.

NuGet Downloads License

What It Does

This package contains 13 Roslyn source generators that eliminate ASP.NET boilerplate:

Minimal API

  • SmartEndpoints — auto-generates complete endpoint registration from your service classes; includes CancellationToken threading, auto-validation, filters, caching, and rate limiting
  • ResultToIResult — converts Result<T> to IResult with domain error-aware HTTP status codes
  • OneOfToIResult — converts OneOf<T1,...,T6> to IResult with tag-based + heuristic error mapping (arities 2–6)

MVC Controllers

  • ResultToActionResult — converts Result<T> to IActionResult with convention-based HTTP mapping
  • OneOfToActionResult — converts OneOf<T1,...,T6> to IActionResult with domain error auto-mapping (arities 2–6)

Cross-cutting

  • OpenAPI metadata — auto-generates .Produces<T>(), .WithSummary(), .WithTags() with accurate error status codes
  • Authorization — generates .RequireAuthorization(), .AllowAnonymous() from attributes
  • [Validate] — generates .Validate() extension methods from DataAnnotations; auto-injected by SmartEndpoints
  • [FluentValidate] — (from REslava.Result.FluentValidation) SmartEndpoints detects [FluentValidate] on body params and auto-injects IValidator<T> as a lambda parameter

Before / After

// Before: Manual endpoint registration (30+ lines per controller)
app.MapGet("/api/products", async (IProductService svc) => {
    var result = await svc.GetProducts();
    return result.Match(
        products => Results.Ok(products),
        errors => Results.BadRequest(errors));
}).WithName("GetProducts").WithTags("Products").Produces<List<Product>>(200).Produces(400);

app.MapGet("/api/products/{id}", async (int id, IProductService svc) => { /* ... */ });
app.MapPost("/api/products", async (CreateProductRequest req, IProductService svc) => { /* ... */ });
// ... repeat for every endpoint

// After: SmartEndpoints (just your business logic)
[AutoGenerateEndpoints(RoutePrefix = "/api/products")]
public class ProductService(AppDbContext db)
{
    public async Task<Result<List<Product>>> GetProducts()
        => Result.Ok(await db.Products.ToListAsync());

    public async Task<Result<Product>> GetProductById(int id)
        => await db.Products.FindAsync(id) is { } p
            ? Result.Ok(p)
            : Result.Fail<Product>("Not found");

    public async Task<Result<Product>> CreateProduct(CreateProductRequest request)
        => Result.Ok(db.Products.Add(new Product(request)).Entity);
}

// In Program.cs — one line:
app.MapProductServiceEndpoints();

Quick Start

dotnet add package REslava.Result
dotnet add package REslava.Result.SourceGenerators
using REslava.Result;

[AutoGenerateEndpoints(RoutePrefix = "/api/users")]
public class UserService(UserRepository repo)
{
    public async Task<Result<User>> GetUserById(int id)
        => await repo.FindAsync(id) is { } user
            ? user    // implicit conversion to Result<User>
            : new NotFoundError($"User {id} not found");
}

// Program.cs
app.MapUserServiceEndpoints();  // auto-generated extension method

The generator infers:

  • HTTP method from name: Get* → GET, Create*/Add* → POST, Update* → PUT, Delete* → DELETE
  • Routes with {id} parameters when methods have an id parameter
  • DI via ASP.NET parameter binding (services injected as lambda parameters)
  • CancellationToken — automatically threaded through when service method declares CancellationToken cancellationToken = default
  • Validation — auto-injects .Validate() when request type carries [Validate]

Requires

MIT License | .NET 8 / 9 / 10

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.

This package has no dependencies.

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.35.0 85 3/2/2026
1.33.0 80 3/1/2026
1.32.0 81 2/28/2026
1.31.0 81 2/27/2026
1.30.0 80 2/27/2026
1.29.0 84 2/25/2026
1.28.0 80 2/25/2026
1.27.0 79 2/25/2026
1.26.0 92 2/24/2026
1.25.0 92 2/23/2026
1.24.0 90 2/23/2026
1.23.0 91 2/23/2026
1.22.0 98 2/18/2026
1.21.0 93 2/17/2026
1.20.0 92 2/17/2026
1.19.0 89 2/16/2026
1.18.0 90 2/16/2026
1.17.0 92 2/16/2026
1.16.0 91 2/16/2026
1.15.0 94 2/16/2026
Loading failed