Mock Data Generator — C# source
Generate deterministic fake data (names, emails, numbers, dates, booleans, UUIDs, pick-from-list) from a schema and a seed. Reproducible output.
This is the C# implementation — the same logic the interactive tool runs, in a shareable, citable form.
// mock-data-generator — C# port of the CosmoDev tool.
// The seeded mulberry32 PRNG (bit-identical to src/lib/mockData.ts and the Go
// twin) drives a representative field set; uint wraps exactly like the JS
// `>>> 0` reference, so the same (schema, count, seed) rebuilds the same rows.
using System;
using System.Collections.Generic;
static class MockData
{
static readonly string[] First =
{ "Ava", "Liam", "Noah", "Emma", "Olivia", "Aiden", "Sophia", "Mason" };
static readonly string[] Last =
{ "Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis" };
// Closure carries the state, mirroring the TS lib's consumption order.
static Func<double> Mulberry32(uint seed) {
uint a = seed;
return () => {
a += 0x6D2B79F5u;
uint t = (a ^ (a >> 15)) * (1u | a); // Math.imul: uint wraps
t = (t + (t ^ (t >> 7)) * (61u | t)) ^ t;
return (t ^ (t >> 14)) / 4294967296.0; // >>> 0, scaled to [0,1)
};
}
// Representative fields from the schema dispatch in mockData.ts.
static object Field(string type, int index, Func<double> rand, int min, int max) {
switch (type) {
case "index":
return index; // no draw
case "email": { // two draws, like TS
string f = First[(int)(rand() * First.Length)].ToLowerInvariant();
string l = Last[(int)(rand() * Last.Length)].ToLowerInvariant();
return $"{f}.{l}@example.com";
}
case "integer":
return min + (int)(rand() * (max - min + 1));
case "boolean":
return rand() < 0.5;
default:
return null; // unknown type -> null
}
}
static void Main() {
var rand = Mulberry32(1234); // seed
var schema = new (string name, string type, int min, int max)[] {
("id", "index", 0, 0),
("email", "email", 0, 0),
("age", "integer", 18, 65),
("active", "boolean", 0, 0),
};
var rows = new List<Dictionary<string, object>>();
for (int i = 0; i < 3; i++) { // count
var row = new Dictionary<string, object>();
foreach (var spec in schema)
row[spec.name] = Field(spec.type, i, rand, spec.min, spec.max);
rows.Add(row);
}
rows.ForEach(r => Console.WriteLine(
$"{{ id={r["id"]}, email={r["email"]}, age={r["age"]}, active={r["active"]} }}"));
}
}
Also available in 13 other languages
Every CosmoDev tool ships its pure logic in TypeScript (web) and Go (CLI), with authored implementations in a dozen-plus languages — the same contract, ported. Compare all languages side by side →