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.
Forge is the root object that every generator lambda receives as its first argument. When you write f => f.Text.Guid() or f => f.Random.Pick(true, false), f is a Forge instance. It holds the underlying random number generator and locale, and it exposes five module properties that give you access to all of Forged’s built-in data generators.
Constructor
Forge is a sealed class with a single constructor:
| Parameter | Default | Description |
|---|---|---|
random | Random.Shared | The Random instance used by every generator in this Forge. Pass a seeded instance for deterministic output. |
locale | CultureInfo.InvariantCulture | The CultureInfo passed to locale-sensitive generators (e.g. title-case, sentence formatting). |
You never instantiate
Forge directly during normal usage. The Faker<TModel> base class creates and owns a Forge instance, and exposes it to your lambdas automatically through the f parameter.Core properties
Forge exposes two data properties alongside its modules:
faker.Forge.Rng from outside the faker if you need the same RNG state elsewhere, but the typical access pattern is through the f parameter inside a lambda.
Generator modules
f.Basic
Literal values and custom functions.
Literal<T>(T value)— always returns the same valueFunc<T>(Func<T> func)— calls a delegate each time
f.Random
Random picks, numbers, weighted picks, and coin toss.
CoinToss()— randomboolPick<T>(params T[] items)— pick one from a setPick<T>(T[] items, int count)— pick many (exact)Pick<T>(T[] items, int min, int max)— pick many (range)Pick<T>()— pick a random enum valueNumber<T>(T? min, T? max)— anyINumber<T>WeightedPick<T>(T[] items, float[] weights)— weighted randomWeightedPick<T>((T item, float weight)[] items)— tuple overload
f.Temporal
Dates, times,
DateTimeOffset, and TimeSpan.Between(DateTime? min, DateTime? max)Past(DateTime? earliest)/Future(DateTime? latest)DateBetween(DateOnly? min, DateOnly? max)DateInPast(DateOnly? earliest)/DateInFuture(DateOnly? latest)TimeBetween(TimeOnly? min, TimeOnly? max)DateTimeOffsetBetween(...)/DateTimeOffsetInPast(...)/DateTimeOffsetInFuture(...)TimeSpanBetween(TimeSpan? min, TimeSpan? max)
f.Text
Strings, GUIDs, Lorem ipsum, templates, and more.
Alpha(int length)/Alpha(int min, int max)Alphanumeric(int length)/Alphanumeric(int min, int max)Pronounceable(int length)/Pronounceable(int min, int max)Hex(int length)/Hex(int min, int max)Lorem(int length)/Lorem(int min, int max)Waffle(int sentences, WaffleStyle style)Guid(GuidGenerator.Kind kind)— V4 by defaultTemplate(string template)
f.Person
Person-related data.
Username(float prefixChance, float suffixChance, float leetChance)— random username with configurable probabilities for prefixes, suffixes, and leet-speak substitutions
How Forge flows through a lambda
When you configure a faker, every property value is a lambda with the signature Func<Forge, IGenerator<T>>. The faker’s Get() method calls each lambda exactly once (on the first invocation), passing this.Forge as the argument:
faker.Forge and the f inside f => f.Text.Alpha(5) are the same object, so all generators within a faker share one Rng instance and one Locale.