Class RandomText
Provides static utility methods for generating random text content at various levels of granularity: individual characters, words, sentences, paragraphs, and multi-sentence blocks of approximate target length.
Inherited Members
Namespace: Scylla.Core.Util.Random
Assembly: ScyllaCore.dll
Syntax
public static class RandomText
Remarks
The generated text is purely random and has no semantic meaning ("gibberish"), making it suitable for procedural content generation, placeholder text during development, UI layout testing, and stress-testing text rendering pipelines.
All methods accept any IRandomSource, enabling deterministic and reproducible text generation when a seeded RNG is provided. The generated content is consistent across platforms for the same seed and RNG algorithm.
GenerateAlphanumeric(IRandomSource, int) delegates to NextAlphanumeric(IRandomSource) from this class for its per-character generation.
Methods
NextAlphanumeric(IRandomSource)
Returns a single random character sampled uniformly from the 62-character alphanumeric set
consisting of lowercase letters (a-z), uppercase letters (A-Z), and digits
(0-9). The character distribution is:
- Index 0-25: lowercase
a-z - Index 26-51: uppercase
A-Z - Index 52-61: digit
0-9
Used by GenerateAlphanumeric(IRandomSource, int) for bulk string generation.
Declaration
public static char NextAlphanumeric(IRandomSource rng)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source used to select the character. |
Returns
| Type | Description |
|---|---|
| char | A randomly selected character from the set |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextDigit(IRandomSource)
Returns a single random decimal digit character sampled uniformly from '0' to '9'.
Declaration
public static char NextDigit(IRandomSource rng)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source used to select the digit. |
Returns
| Type | Description |
|---|---|
| char | A randomly selected character in the range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextLetter(IRandomSource, bool)
Returns a single random letter character sampled uniformly from the 26-letter English alphabet.
The case of the returned character is controlled by uppercase.
Declaration
public static char NextLetter(IRandomSource rng, bool uppercase = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source used to select the letter. |
| bool | uppercase | When |
Returns
| Type | Description |
|---|---|
| char | A randomly selected ASCII letter character. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextParagraph(IRandomSource)
Generates a random gibberish paragraph whose sentence count is chosen uniformly from 3 to 6 (inclusive). Equivalent to calling NextParagraph(IRandomSource, int) with a sentence count drawn from [3, 6].
Declaration
public static string NextParagraph(IRandomSource rng)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for sentence count selection and sentence generation. |
Returns
| Type | Description |
|---|---|
| string | A space-joined string of 3 to 6 random sentences. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextParagraph(IRandomSource, int)
Generates a random gibberish paragraph consisting of exactly sentenceCount
sentences. Sentences are separated by a single space. Each sentence is produced by
NextSentence(IRandomSource) (4-10 words, capitalized first word, period
terminated).
Declaration
public static string NextParagraph(IRandomSource rng, int sentenceCount)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for sentence generation. |
| int | sentenceCount | The exact number of sentences in the paragraph. Must be at least 1. |
Returns
| Type | Description |
|---|---|
| string | A space-joined string of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |
See Also
NextSentence(IRandomSource)
Generates a random gibberish sentence whose word count is chosen uniformly from 4 to 10 (inclusive). Equivalent to calling NextSentence(IRandomSource, int) with a word count drawn from [4, 10].
Declaration
public static string NextSentence(IRandomSource rng)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for word count selection and word generation. |
Returns
| Type | Description |
|---|---|
| string | A space-separated string of 4 to 10 random words ending with a period. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextSentence(IRandomSource, int)
Generates a random gibberish sentence consisting of exactly wordCount words.
The first word is capitalized; all subsequent words are lowercase. Words are separated by
single spaces and the sentence is terminated with a period character.
Declaration
public static string NextSentence(IRandomSource rng, int wordCount)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for word generation. |
| int | wordCount | The exact number of words in the sentence. Must be at least 1. |
Returns
| Type | Description |
|---|---|
| string | A space-separated string of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |
See Also
NextText(IRandomSource, int)
Generates a block of random gibberish text composed of full sentences, targeting a total
character length of approximately approximateLength characters.
Sentences are appended one at a time (separated by a single space) until the accumulated
length meets or exceeds the target. Because sentences are never truncated, the actual
length of the result will typically be slightly greater than approximateLength.
Declaration
public static string NextText(IRandomSource rng, int approximateLength)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for sentence generation. |
| int | approximateLength | The minimum character count at which sentence appending stops. The actual result length will be at least this value, rounded up to the end of the last complete sentence. Must be at least 1. |
Returns
| Type | Description |
|---|---|
| string | A string of one or more random sentences whose total character count is at least
|
Remarks
The overshoot per call is bounded by the length of a single sentence (typically 30-80
characters for the default word-count range). For very small values of
approximateLength, the result may be substantially longer than the
target - the minimum output is always at least one complete sentence.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |
See Also
NextWord(IRandomSource, bool)
Generates a random gibberish word with a length chosen uniformly from the typical
English word length range of 3 to 8 characters (inclusive). Equivalent to calling
NextWord(IRandomSource, int, int, bool) with minLength = 3
and maxLength = 8.
Declaration
public static string NextWord(IRandomSource rng, bool capitalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for length selection and letter generation. |
| bool | capitalize | When |
Returns
| Type | Description |
|---|---|
| string | A string of 3 to 8 random lowercase letters (with optional capitalization). |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
See Also
NextWord(IRandomSource, int, bool)
Generates a random gibberish word of exactly length letters.
The word consists entirely of alphabetic characters with no spaces or punctuation.
If capitalize is true, the first character is produced by
NextLetter(IRandomSource, bool) with uppercase = true;
all remaining characters are lowercase.
Declaration
public static string NextWord(IRandomSource rng, int length, bool capitalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for letter selection. |
| int | length | The exact number of characters in the returned word. Must be at least 1. |
| bool | capitalize | When |
Returns
| Type | Description |
|---|---|
| string | A string of exactly |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |
See Also
NextWord(IRandomSource, int, int, bool)
Generates a random gibberish word whose length is chosen uniformly from the inclusive range
[minLength, maxLength]. Delegates to
NextWord(IRandomSource, int, bool) once the length is selected.
Declaration
public static string NextWord(IRandomSource rng, int minLength, int maxLength, bool capitalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IRandomSource | rng | The random source to use for length selection and letter generation. |
| int | minLength | The minimum word length (inclusive). Must be at least 1. |
| int | maxLength | The maximum word length (inclusive). Must be greater than or equal to
|
| bool | capitalize | When |
Returns
| Type | Description |
|---|---|
| string | A string of random lowercase letters (with optional capitalization) whose length is in [ |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentOutOfRangeException | Thrown if |