Forged is a fast, strict, and strongly-typed fake data generator for C# that leverages Roslyn Source Generators to eliminate the guesswork from test data creation. Unlike reflection-based fakers — which discover your model’s shape at runtime and can silently skip required properties or assign values of the wrong type — Forged generates a dedicatedDocumentation 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.
{ModelName}Faker class at compile time. This means the compiler itself enforces that every required property has a generator configured, that nullability contracts are respected, and that all types match exactly. If your test data setup is wrong, you find out during the build, not during a test run.
Source Generated
The faker class for your model is emitted by a Roslyn Source Generator at build time. There is no reflection at runtime, making Forged fully compatible with ahead-of-time (AOT) compilation and trimming.
Strict & Type-Safe
Every public, settable property on your model becomes a strongly-typed property on the faker. If a model property is
required, the corresponding faker property is also required — the compiler rejects incomplete configurations.Fluent API
Generators are composed through a clean, chainable fluent API. You can transform, filter, combine, and collect generated values using readable pipelines without any magic strings or reflection.
Deterministic
Pass a seeded
Random instance to the faker constructor to reproduce the exact same sequence of fake values every time — ideal for snapshot tests, reproducible CI failures, and data-driven scenarios.How It Works
The core workflow has three steps: annotate your model, let the generator produce a faker class, then configure and call it. 1. Annotate your model with[Fake] from the Forged.Core namespace:
PersonFaker class (saved as PersonFaker.g.cs in your build output). You never write or maintain this file — it is regenerated whenever your model changes.
3. Configure the faker and call Get() to produce fake instances:
f parameter in each lambda is a Forge instance — the root object that exposes all generator modules (f.Text, f.Temporal, f.Random, f.Basic, f.Person). Each module returns a Generator<T> that you can chain with fluent modifiers before handing it back to the faker.
Properties marked
required on your model are also marked required on the generated faker. Omitting a generator for any required property is a compile-time error, not a runtime surprise. Optional (non-required) faker properties can be left null — their model properties will receive default when Get() is called.Package Information
| Detail | Value |
|---|---|
| NuGet package | Atulin.Forged |
| Current version | 0.3.0 |
| Target framework | .NET 10 |
| License | MIT |
| Repository | github.com/Atulin/Forged |