Xfty 1.0.0-beta.5

This is a prerelease version of Xfty.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Xfty --version 1.0.0-beta.5
                    
NuGet\Install-Package Xfty -Version 1.0.0-beta.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xfty" Version="1.0.0-beta.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xfty" Version="1.0.0-beta.5" />
                    
Directory.Packages.props
<PackageReference Include="Xfty" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Xfty --version 1.0.0-beta.5
                    
#r "nuget: Xfty, 1.0.0-beta.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Xfty@1.0.0-beta.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Xfty&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Xfty&version=1.0.0-beta.5&prerelease
                    
Install as a Cake Tool

XFTY — Extreme C# Test Data Factory

CI

XFTY is a declarative test data factory for C#.

Instead of manually constructing complete object graphs for every test, you describe only the values your test actually cares about. XFTY supplies sensible defaults, automatically creates related records, and either mocks persistence entirely or actually inserts through a pluggable IPersistenceGateway — the same Provider definitions serve a pure in-memory unit test and a real database integration test.

By centralizing test data definitions, XFTY dramatically reduces boilerplate and makes tests more resilient to changing validation rules, required fields, and evolving business logic.


Why XFTY?

As a project grows, so does the amount of code required simply to create valid test data.

A Contact requires an Account. Later, a validation rule requires additional Account fields. Eventually another related type becomes mandatory. Over time, hundreds or even thousands of tests can end up duplicating nearly identical setup code.

XFTY centralizes that knowledge.

Instead of every test knowing how to construct a valid object graph, Providers define that logic once, allowing individual tests to override only the fields they actually care about.

The result is test code that is:

  • shorter
  • easier to read
  • easier to maintain
  • more resilient to application changes

Features

Core Generation

  • Declarative test data generation, described once per Provider
  • Automatic relationship generation — required, optional, shared ancestors, self-referential cycles guarded automatically
  • Context-aware values: a field derived from a sibling, a generated ancestor, or (once the graph exists) a generated child, with a loud error on a mis-ordered read instead of a silent wrong null
  • Per-call relationship control (IncludeOptional, ExcludeRelationship) without touching a Provider's own definition
  • Lambda-based field access throughout (x => x.Field, not a bare PropertyInfo or nameof(...))

Persistence

  • Real persistence through IPersistenceGateway — Xfty.EntityFrameworkCore ships an EF Core implementation, proven against SQLite and a real Postgres container — or mock Ids with no database touched at all
  • Deferred and depth-batched insert: build a graph across several calls, then insert it once, in dependency order, across mixed record types
  • Suitable for both isolated unit tests and real-database integration tests, with the same Provider definitions

Provider Architecture

  • Extensible Provider architecture — implement IRecordProvider directly, or use SimpleRecordProvider<T> when a Provider is nothing but a template
  • Multi-variant Providers (FlavouredLookupKey, DiscriminatorLookupKey) — resolve a different Provider for the same type by an arbitrary predicate or field value

Packages & Platform Support

  • Optional add-on packages for common conveniences core Xfty doesn't bundle: Xfty.Bogus (realistic names/emails/addresses/paragraphs), Xfty.VectorDatabases (a random-vector value expression for an embedding field), Xfty.AutoFixture, and Xfty.AutoBogus (both: point Create<T>()/Generate<T>() at a RecordProvider, and/or let the tool fill fields no Provider declares), and Xfty.FSharpAsync (Async<'T> wrappers, for F# code on the original async { } workflow) — none is a dependency of core Xfty itself
  • Targets netstandard2.0/net8.0/net10.0 — .NET Framework 4.6.1+, Mono/Xamarin, and older .NET Core all work, not just current .NET

See How XFTY compares for how this stacks up against AutoFixture, Bogus, and similar libraries.


Quick Example

Generate a Contact with sensible defaults:

DefaultProviderLookup lookup = new();

Contact contact = (Contact)await new RecordProvider(typeof(Contact), lookup)
    .Supply();

Override only the fields your test actually cares about:

Contact contact = (Contact)await new RecordProvider(typeof(Contact), lookup)
    .Put<Contact>(x => x.FirstName, "Alice")
    .SetInsertMode(InsertMode.Mock)
    .Supply();

Generate complete related object graphs:

Bundle bundle = await new RecordProvider(typeof(Contact), lookup)
    .SetInsertMode(InsertMode.Mock)
    .SetInclusivity(InsertInclusivity.All)
    .SupplyBundle();

Contact contact = (Contact)bundle.GetList<Contact>(x => x.Id)![0];
Account account = (Account)bundle.GetList<Contact>(x => x.AccountId)![0];

Assert.Equal(account.Id, contact.AccountId);

Documentation

Full documentation is in docs/, organised by audience:

I want to… Go to
Use XFTY to write tests docs/use/ — start with getting-started
Teach XFTY about my own record types docs/extend/
Work on XFTY itself docs/contribute/ — architecture
Look something up docs/reference/ — api-cheatsheet, known-issues
See what's built / planned docs/roadmap/

Design Philosophy

XFTY was designed around a simple idea:

Tests should describe only what makes them unique.

Everything else should be generated automatically.

Rather than scattering test data throughout an entire codebase, XFTY moves that knowledge into reusable Providers that declaratively describe valid records and their relationships.

The framework then constructs those object graphs automatically, allowing test code to remain focused on the behaviour being tested rather than on setup.


How XFTY Compares

XFTY is not a general-purpose "fill in an object" library like AutoFixture, and it doesn't ship realistic fake-data generators like Bogus. What it does that they don't:

  • Generates a related graph — required/optional relationships, shared ancestors deduplicated across many children, self-referential cycles guarded automatically — not one object at a time.
  • Has an actual opinion about persistence: the same Provider definitions run as a pure in-memory Mock in a unit test, or insert for real through IPersistenceGateway in an integration test, with no rewrite.
  • Resolves a different Provider variant for the same type by a runtime key or predicate, and supports context-aware values — a field derived from a sibling, ancestor, or generated child, with a loud guard against reading one that hasn't been generated yet.

Core Xfty has no built-in realistic fake-data generation (Xfty.Bogus is an optional add-on for that) and no auto-population by default - every field a Provider cares about is declared, not guessed. Xfty.AutoFixture and Xfty.AutoBogus are optional pairings for the fields a Provider doesn't care about (or for pointing the tool's own generation at a Provider directly) - neither changes core Xfty's own philosophy. See docs/reference/comparison.md for the full, unvarnished comparison against AutoFixture, Bogus, AutoBogus, and NBuilder, including where XFTY is a worse fit than any of them.


Roadmap

Recently landed (see the CHANGELOG for the full detail, including everything since the 1.0.0-beta.1 tag):

New Packages

  • Xfty.Bogus and Xfty.VectorDatabases — optional packages for realistic fake data and vector-embedding fields, without adding either dependency to core Xfty
  • Xfty.AutoFixture — pairs XFTY with AutoFixture both directions: point fixture.Create<T>() at a registered RecordProvider, and/or let AutoFixture fill in whatever fields a Provider's Master Template left unset
  • Xfty.AutoBogus — the same pairing for AutoBogus (AutoFixture-style auto-population plus Bogus's realistic generators), completing the trifecta: XFTY now pairs with AutoFixture, Bogus, and AutoBogus
  • Xfty.Xunit — [IsolatesSharedAncestor], resetting SharedAncestor before/after a test class or method automatically
  • Xfty.FSharpAsync — Async<'T> wrappers for F# code still built on async { } rather than the newer task { }, which needs no wrapper at all

Core Engine

  • DiscriminatorLookupKey — resolving a Provider by a field's value
  • Lambda-based field access across the whole public API
  • Typed RecordProvider<TRecord>/ChildProvider<TChild> wrappers — no cast at the Supply() call site, plus a MasterTemplate<TRecord>-style object-initializer indexer
  • Real persistence via IPersistenceGateway (Xfty.EntityFrameworkCore, proven against SQLite and a real Postgres container)
  • Persistence is fully async end to end — every Supply/SupplyList/ SupplyBundle call, and everything reachable from it, is now genuinely Task-based, matching how every real backing store (EF Core, a vector database client, a network call) already works underneath

Platform & Reliability

  • A full sweep to a from-scratch, idiomatic C# port with no remaining Salesforce-specific surface
  • A real, fixed thread-safety issue in SharedAncestor under concurrent test execution (xUnit's default; this repo's own suite had opted out)
  • Core Xfty now multi-targets netstandard2.0;net8.0;net10.0, reaching .NET Framework 4.6.1+/Mono/Xamarin as well as modern .NET, verified via a dedicated net472 test project (netstandard2.0 isn't itself runnable)

The full status table — built, not-ported, and open ideas under consideration (embedded/denormalized document relationships) — is docs/roadmap/README.md.


Contributing

Contributions, bug reports, feature requests, and discussions are welcome.

If you would like to contribute:

  • Open an issue to discuss proposed changes.
  • Keep Provider implementations declarative whenever possible.
  • Preserve backwards compatibility unless a compelling reason exists not to.
  • Prefer simplicity and readability over additional abstraction.

License

This project is released under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on Xfty:

Package Downloads
Xfty.EntityFrameworkCore

An IPersisting implementation for XFTY that inserts generated records through Entity Framework Core, instead of mocking them.

Xfty.Xunit

xUnit integration for XFTY: [IsolatesSharedAncestor], an attribute for a test class or method that resets SharedAncestor's registry before and after - so a consumer never has to hand-wire a base test class or fixture to keep shared-ancestor state from leaking between tests.

Xfty.AutoFixture

Pairs XFTY with AutoFixture: point a Fixture's Create<T>() at a registered RecordProvider instead of AutoFixture's own generation, and/or let AutoFixture fill in whatever fields a Provider's Master Template left unset.

Xfty.VectorDatabases

A bundled IValueYielding for XFTY that fills a vector-database record's embedding field with a fixed-length array of random floats - structurally a vector, not a semantically meaningful embedding.

Xfty.Bogus

Bundled IValueExpressions for XFTY that produce realistic-looking fake data - names, emails, addresses, paragraphs - by wrapping Bogus, instead of every Provider writing its own.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta.13 2,361 10/9/2026
1.0.0-beta.12 380 9/18/2026
1.0.0-beta.11 126 9/10/2026
1.0.0-beta.10 360 9/10/2026
1.0.0-beta.9 129 9/10/2026
1.0.0-beta.8 118 9/10/2026
1.0.0-beta.7 128 9/7/2026
1.0.0-beta.6 143 9/7/2026
1.0.0-beta.5 121 9/6/2026
1.0.0-beta.3 132 9/6/2026
1.0.0-beta.2 120 9/6/2026
1.0.0-beta.1 131 9/6/2026