Nullean.Entities.CsCheck.AutoBogus
0.1.1
dotnet add package Nullean.Entities.CsCheck.AutoBogus --version 0.1.1
NuGet\Install-Package Nullean.Entities.CsCheck.AutoBogus -Version 0.1.1
<PackageReference Include="Nullean.Entities.CsCheck.AutoBogus" Version="0.1.1" />
<PackageVersion Include="Nullean.Entities.CsCheck.AutoBogus" Version="0.1.1" />
<PackageReference Include="Nullean.Entities.CsCheck.AutoBogus" />
paket add Nullean.Entities.CsCheck.AutoBogus --version 0.1.1
#r "nuget: Nullean.Entities.CsCheck.AutoBogus, 0.1.1"
#:package Nullean.Entities.CsCheck.AutoBogus@0.1.1
#addin nuget:?package=Nullean.Entities.CsCheck.AutoBogus&version=0.1.1
#tool nuget:?package=Nullean.Entities.CsCheck.AutoBogus&version=0.1.1
Nullean.Entities.CsCheck.AutoBogus

Keep your existing AutoFaker setup (binders, per-type overrides, skip rules) and still get reproducible, shrinkable property-test data.
GenAuto.Of<T>() in Nullean.Entities.CsCheck builds any type itself: lock-free, shrinkable, plausible values mixed with edge cases (blank and hostile strings, NaN, negatives, undefined enums, Start == End). This package is the alternative for a team that already configures AutoFaker, or that wants strictly plausible Bogus data. GenAutoBogus.Of<T>() returns a CsCheck Gen<T> backed by AutoFaker, with every draw routed through CsCheck's PCG.
It is optional and not the default. It builds on Nullean.Entities.CsCheck, depends on Soenneker.Utils.AutoBogus, uses reflection, and is not trim or AOT clean. It targets net10.0 and net11.0.
Install
dotnet add package Nullean.Entities.CsCheck.AutoBogus
It brings Nullean.Entities.CsCheck and Soenneker.Utils.AutoBogus. Put it in a test project.
Get going
Draw values and check a property. A failing property reports a seed, and the value shrinks:
using CsCheck;
using Nullean.Entities.CsCheck.AutoBogus;
internal sealed record Line(string Sku, int Quantity, decimal Price);
internal sealed record Cart(string Owner, List<Line> Lines);
public class CartTests
{
[Test]
public void Owner_is_short()
{
// fails on purpose: Bogus names are longer than two characters
GenAutoBogus.Of<Cart>().Sample(c => c.Owner.Length <= 2, iter: 500);
}
}
The failure is a CsCheckException whose message contains Set seed: re-run with that seed and you get the same value. The test uses TUnit attributes, the framework this repository's tests use.
Configure the AutoFaker once; the delegate runs once per thread, on first use:
Gen<Cart> carts = GenAutoBogus.Of<Cart>(faker =>
{
// your AutoFaker configuration: binders, overrides, skip rules
});
The value: your Bogus investment, reproducible
Every draw goes through CsCheck's PCG, so values are reproducible by seed and shrink by draw count and magnitude. The Gen<T> plugs into any API that takes one, including the constraint helpers in Nullean.Entities.CsCheck:
using Nullean.Entities;
using Nullean.Entities.CsCheck;
var rules = ConstraintSet.From(("HasOwner", Constraints<Cart>.Always(c => c.Owner.Length > 0, "owner is required")));
rules.ForAll(c => c.Owner.Length > 0, GenAutoBogus.Of<Cart>(), iter: 100);
Pass it as gen: to ForAll and Probe, or as start: to Preserves (Preserves also needs the entity's EntityActions<T>).
Which generator to choose
GenAuto.Of<T>() (default) |
GenAutoBogus.Of<T>() |
|
|---|---|---|
| Values | plausible mixed with edge cases | plausible only |
| Rules it can break (25 example domains, 64 rules) | 59 of 64 | 32 of 64 |
| Threads | lock-free, scales | stops scaling at about two threads |
Existing AutoFaker configuration |
AutoOptions.Use<T>(gen) |
kept |
| Some non-public-constructor and abstract types | fails with a clear message | may build them |
Choose this package when the AutoFaker configuration is worth keeping. The measurements behind the split are in docs/autobogus-decision.md.
What you get
GenAutoBogus.Of<T>(Action<AutoFaker>? configure = null): aGen<T>that populates every public member ofTwith AutoBogus data, in namespaceNullean.Entities.CsCheck.AutoBogus.
Pitfalls and limits
- It generates plausible values only. No NaN, negatives, blank strings or undefined enums, so
Probereports most rules as "never violated" andRejectsInvalidas unfalsifiable. That is the main reason it is not the default. - Bogus's global lock.
Randomizer.Lockeris aninternal statictaken inside every draw and cannot be disabled, so a multi-threaded CsCheck run stops scaling at about two threads (measured: 71kOrderdraws/second on one thread, 97k on eight, against 617k and 1.6M forGenAuto.Of<Order>()). IndexFaker/IndexVariableare reset to zero before every draw, so a rule readingf.IndexFakeris reproducible.f.IndexGlobal,f.UniqueIndexandFaker.GlobalUniqueIndexare process-wide statics shared with every otherFaker: avoid them.configureruns once per thread, not once per sample: keep it pure.- Output depends on the installed Bogus dataset version, so a Bogus update can change what a seed produces.
Next
- The default generator and the constraint helpers:
Nullean.Entities.CsCheck - Why this is optional, with measurements: https://github.com/nullean/entities/blob/main/docs/autobogus-decision.md
- Generated data reference: https://entities.nullean.net/reference/generated-data/
- Testing API reference: https://entities.nullean.net/reference/testing-api/
- Getting started: https://entities.nullean.net/getting-started/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Nullean.Entities.CsCheck (>= 0.1.1)
- Soenneker.Utils.AutoBogus (>= 4.0.966)
-
net11.0
- Nullean.Entities.CsCheck (>= 0.1.1)
- Soenneker.Utils.AutoBogus (>= 4.0.966)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.1 | 63 | 10/20/2026 |
| 0.1.0 | 50 | 10/20/2026 |
| 0.1.0-preview.2 | 45 | 10/20/2026 |
| 0.1.0-preview.1 | 42 | 10/20/2026 |