Every type decorated withDocumentation 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.
[Fake] gets a compile-time-generated subclass of Faker<TModel>. This subclass exposes one lambda property per public settable property on your model, and provides a Get() method that invokes those lambdas to produce fully populated instances. You configure the faker once by supplying generator lambdas, then call Get() as many times as you need.
The Faker<TModel> base class
Faker<TModel> is an abstract generic class defined in Forged.Core. The generated subclass inherits from it automatically — you never write the inheritance yourself.
| Parameter | Default | Purpose |
|---|---|---|
random | null | Passed to the internal Forge; falls back to Random.Shared when null |
locale | null | Passed to the internal Forge; falls back to CultureInfo.InvariantCulture when null |
Forge property exposes the Forge instance that the faker creates from those arguments. All generator lambdas receive this same Forge instance as their f parameter.
The source-generated subclass constructor only exposes the
random parameter — it does not surface locale. The emitted signature is always public {Name}Faker(Random? random = null) : base(random) { }. If you need a non-default locale, subclass Faker<TModel> manually and pass your CultureInfo to base(random, locale).The three Get overloads
Forge.Rng.Next(min, max) to pick the count, so the actual number of items produced varies between calls.
Generator lambda caching
Each lambda property has a backing private field (e.g._idGenerator). The generated Get() implementation uses the ??= pattern to invoke a lambda only once per faker lifetime and cache the resulting IGenerator<T>:
- Lambdas are evaluated once on the first call to
Get(). - Subsequent calls reuse the same generator instances — keeping any internal state (e.g. memo caches) intact across the lifetime of the faker.
Complete example
The demo application configuresPersonFaker with a full set of generator lambdas using real Forged modules: