-
Notifications
You must be signed in to change notification settings - Fork 24
Reproducible Names
A seeded generator gives the same names every time, on every operating system and on every .NET runtime. This page says what that guarantee covers.
var a = new PersonNameGenerator(42);
var b = new PersonNameGenerator(new Random(42));
var c = new Random(42);
a.GenerateRandomFemaleFirstName(); // "Marguerita"
b.GenerateRandomFemaleFirstName(); // "Marguerita"
c.GenerateRandomFemaleFirstName(); // "Marguerita"All three draw from new Random(42). The difference is who owns the Random. a and b keep theirs for the next call. c is yours, so you can hand it to other generators or roll your own dice with it between calls.
A seeded Random uses the same algorithm on .NET Framework and on modern .NET; the newer algorithm applies only to an unseeded Random and to Random.Shared. So new PersonNameGenerator(42) gives Alisa Streets on .NET Framework 4.8 and on .NET 10 alike. The repository's golden tests hold every answer the published 2.2.0 gave on each runtime and confirm this on every build.
Every method makes exactly these calls on the Random, in this order, and nothing else.
| Method | Calls |
|---|---|
GenerateRandomLastName, GenerateRandomMaleFirstName, GenerateRandomFemaleFirstName, GenerateRandomPlaceName, GenerateRandomStarName, GenerateRandomProperStarName
|
One Next(0, listLength). |
GenerateRandomFirstName |
Next(0, 2), then one Next(0, listLength) on the male list when that gave 0, otherwise on the female list. |
GenerateRandomFirstAndLastName |
As GenerateRandomFirstName, then as GenerateRandomLastName: three calls. |
GenerateRandomMaleFirstAndLastName, GenerateRandomFemaleFirstAndLastName
|
Two calls: the first name, then the last name. |
GenerateRandomCatalogStarName |
One Next(0, 343518). A result below 225,300 becomes HD plus the result plus one; anything else indexes the Hipparcos numbers. |
GenerateMultiple...(n) |
The single method's calls, n times. |
| Extension methods | The same as the method of the same name, on a fresh generator around your Random. |
Two consequences follow. The list lengths are part of the arithmetic, so a list change changes every seeded name drawn from that list. And the sequence of calls is part of the result, so a Random shared between generators gives names that depend on the order you call them in.
| Names | Same as 1.2.2? | Changed in |
|---|---|---|
| Person names | yes | never |
| Place names | no | 2.1.0 (duplicates removed, accents fixed) and 2.3.0 (list rebuilt without truncated names) |
| Star names | new in 2.2.0 |
The maintainer treats every recorded answer as a contract. The golden tests replay 426 calls per runtime, recorded from the published 2.2.0, against every build. A change to any answer needs a written decision and a changelog line, and the place list is the one exception so far. If exact seeded output matters to you, pin the version in your project file (Version="[2.3.0]") and read the CHANGELOG before moving.
- The default constructor is random by design; two default generators never agree.
- A seeded generator belongs to one thread. Two threads on one
Randomcorrupt it and make the order of calls unrepeatable. - Different seeds can still give the same name, since there are only so many names on a list.
- Culture has no effect: names are picked by index and catalogue numbers are formatted with the invariant culture.
The README's rows of example names come from new Random(20260924) and one GenerateMultiple...(8) call per row; the proper and catalogue star rows come from eight single calls on one generator. A test in the repository checks that they still reproduce, so the README cannot go stale without a failing build.
This wiki describes RandomNameGeneratorLibrary 2.3.0 and was last updated on 2026-09-30. The library is MIT licensed. Report problems in the issues.