Skip to main content
.NETStandard2.0

This project uses Source Generation to create a FluentBuilder for a specified model-class or DTO.

Published
Jul 15, 2025
1y ago
Total Downloads
215.7K
215,672

Install

dotnet add package FluentBuilder --version 0.10.0.3-preview-01
ProductVersions
.NET Standard
netstandard2.0

README

Usage

:one: Annotate a class

Annotate a class with [AutoGenerateBuilder] to indicate that a FluentBuilder should be generated for this class:

[AutoGenerateBuilder]
public class User
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public DateTime? Date { get; set; }
}

:two: Define a class which needs to act as a builder

This scenario is very usefull when you cannot modify the class to annotate it.

Create a public and partial builder class

And annotate this class with [AutoGenerateBuilder(typeof(XXX))] where XXX is the type for which you want to generate a FluentBuilder.

[AutoGenerateBuilder(typeof(UserDto))]
public partial class MyUserDtoBuilder
{
}

Use FluentBuilder

using System;

namespace Test;

class Program
{
    static void Main(string[] args)
    {
        var user = new UserBuilder()
            .WithFirstName("Test")
            .WithLastName("User")
            .Build();

        Console.WriteLine($"{user.FirstName} {user.LastName}");
    }
}

For more information, see the StefH/FluentBuilder.

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of FluentBuilder.

Entity Framework Extensions

Dapper Plus

Changes from Previous Version

No structural changes between v0.10.0.2 and v0.10.0.3-preview-01.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.