Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/atulin/forged/llms.txt

Use this file to discover all available pages before exploring further.

Forged is a fast, strict, and strongly-typed data generator for C#. Powered by Roslyn Source Generators, it creates Faker<T> classes at compile time from your models — so you get IntelliSense, compile-time errors for missing required properties, and zero reflection overhead.

Quickstart

Get fake data flowing in under five minutes with a complete working example.

Installation

Add Forged to your project via NuGet and configure the source generator.

Core Concepts

Understand how the [Fake] attribute, Forge, and generators fit together.

API Reference

Browse every built-in generator module and extension method with signatures.

Why Forged?

Most faker libraries rely on reflection and convention-based property matching. Forged takes a different approach: the C# compiler generates your faker class at build time, and it mirrors your model’s property requirements exactly.

Compile-Time Safety

If a model property is required, the generated faker makes its generator required too — you cannot call new PersonFaker() without providing all required fields.

No Reflection

Everything is generated as plain C# code. Fully compatible with Native AOT and trimming — no runtime type inspection needed.

Fluent Pipeline API

Chain modifiers like .Capitalize(), .OrNull(0.2f), .List(3, 5), and .Refine(x => ...) to compose rich generation pipelines.

Deterministic Output

Pass a seeded Random instance to reproduce the exact same dataset every run — perfect for snapshot tests.

Quick Example

using Forged.Core;

[Fake]
public class Product
{
    public required Guid Id { get; set; }
    public required string Name { get; set; }
    public decimal Price { get; set; }
    public bool IsAvailable { get; set; }
}
The source generator emits ProductFaker. Configure it and generate data:
var faker = new ProductFaker
{
    Id    = f => f.Text.Guid(),
    Name  = f => f.Text.Pronounceable(2, 4).Capitalize(),
    Price = f => f.Random.Number<decimal>(1m, 999m),
};

var product  = faker.Get();       // one item
var products = faker.Get(20);     // twenty items
1

Install the NuGet package

Add Atulin.Forged to your project. The package bundles both the runtime library and the source generator.
2

Annotate your model

Decorate any class or record with [Fake] from Forged.Core.
3

Configure the generated faker

Instantiate the generated {Model}Faker, providing a generator lambda for each property.
4

Call Get() to generate data

Call faker.Get() for a single instance or faker.Get(n) for a collection.

Build docs developers (and LLMs) love