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.
ForgeRandom is the core randomisation module in Forged, accessible via f.Random. It covers the most common random-data patterns: flipping a coin, drawing one or more items from a fixed collection, picking a random enum member, generating a numeric value in a range, and performing probability-weighted selection. Every method returns a Generator<T> that is re-evaluated on each call to Generate(), so every record in a batch gets independently randomised values.
CoinToss
Simulates a coin flip, producing a uniformly distributedbool — true for heads, false for tails.
Produces
true or false with equal probability on each invocation.Pick<T> — single item
Randomly selects one item from a supplied set of values. Pass the candidates directly as arguments; the method uses aparams array so no explicit array construction is required.
One or more candidate values to choose from. Each call selects a single item
uniformly at random.
Produces one randomly chosen element from
items on each invocation.Pick<T> — fixed count
Picks exactlycount items (with replacement) from items and returns them as an array.
The source collection to draw from.
The exact number of items to include in the returned array.
Produces a
T[] of length count on each invocation.Pick<T> — variable count
Picks a random number of items betweenminCount and maxCount (inclusive) from items.
The source collection to draw from.
The minimum number of items to include (inclusive).
The maximum number of items to include (inclusive).
Produces a
T[] whose length varies between minCount and maxCount on each invocation.Pick<T> — enum value
Randomly selects one value from astruct enum type T. The generator caches the enum’s values on first use, so there is no repeated reflection cost.
Produces a randomly chosen member of the enum
T on each invocation.Number<T>
Generates a random numeric value within an inclusive[min, max] range. The constraint where T : struct, INumber<T>, IMinMaxValue<T> means it supports all built-in .NET numeric primitives — int, long, float, double, decimal, short, byte, uint, and more. When min or max is omitted the type’s MinValue / MaxValue is used automatically.
The lower bound of the range (inclusive). Defaults to
T.MinValue when null.The upper bound of the range (inclusive). Defaults to
T.MaxValue when null.Produces a random value of type
T within the specified range on each invocation.WeightedPick<T> — parallel arrays
Picks one item fromitems using probability weights supplied as a parallel float[]. Items with higher weights appear more frequently. The weights do not need to sum to 1 — they are normalised internally.
The candidate values. Must have the same length as
weights.A weight for each item at the corresponding index. Higher values increase
selection probability. Must have the same length as
items.Produces one item from
items on each invocation, chosen proportionally to its weight.WeightedPick<T> — tuple pairs
An alternative overload that accepts item-weight pairs as a single array of(T item, float weight) tuples, keeping each item co-located with its weight for improved readability.
An array of tuples where each element pairs a candidate value with its relative
weight. Higher weight values increase the probability of that item being selected.
Produces one item on each invocation, chosen proportionally to its paired weight.