This guide walks you through everything needed to produce your first fake C# object with Forged. By the end you will have installed the package, annotated a model class, configured the generated faker, and calledDocumentation 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.
Get() to produce both single and multiple fake instances — all with full compile-time type checking.
Install Atulin.Forged
Add the package to your .NET 10 project using the .NET CLI:This single package bundles both the runtime library (
Forged.Core.dll) and the Roslyn Source Generator (Forged.Generator.dll). No additional setup is required — the generator activates automatically on the next build.Annotate your model with [Fake]
Decorate any Build the project once after adding the attribute. The source generator emits a
class or record with the [Fake] attribute from the Forged.Core namespace. The example below is the Person model used throughout the Forged demo project:PersonFaker.g.cs file containing the PersonFaker class — visible in your IDE under Dependencies → Analyzers → Forged.Generator.Configure the generated PersonFaker
Instantiate
PersonFaker using an object initializer. Each property accepts a lambda Func<Forge, IGenerator<T>> — the f parameter exposes all built-in generator modules. The following example is taken directly from the Forged demo project and demonstrates a range of generator features:Generate fake data
Call Each call to
Get() to produce a single instance, Get(int count) for an exact number, or Get(int min, int max) for a random count within a range:Get() runs every configured generator pipeline once and assembles a new model instance. Generators are lazily initialized on the first call and reused on subsequent calls, so the pipeline is only built once per faker instance.For reproducible output — useful in unit tests or snapshot comparisons — pass a seeded Every call to
Random instance to the faker constructor:faker.Get() on a seeded faker produces the same sequence of values, regardless of environment or run order.