Swevo.AutoTestData
1.0.0
Prefix Reserved
dotnet add package Swevo.AutoTestData --version 1.0.0
NuGet\Install-Package Swevo.AutoTestData -Version 1.0.0
<PackageReference Include="Swevo.AutoTestData" Version="1.0.0" />
<PackageVersion Include="Swevo.AutoTestData" Version="1.0.0" />
<PackageReference Include="Swevo.AutoTestData" />
paket add Swevo.AutoTestData --version 1.0.0
#r "nuget: Swevo.AutoTestData, 1.0.0"
#:package Swevo.AutoTestData@1.0.0
#addin nuget:?package=Swevo.AutoTestData&version=1.0.0
#tool nuget:?package=Swevo.AutoTestData&version=1.0.0
Swevo.AutoTestData
Compile-time test data builders for .NET, generated by a Roslyn incremental source generator. An AutoFixture / Bogus alternative with zero reflection, zero runtime overhead, and full AOT/trim support — the fake-value logic is generated as plain C# at build time, not discovered by walking your object graph at runtime.
Why
Reflection-based fakers (AutoFixture, Bogus) work great, but they:
- Add startup/runtime cost inspecting your types via reflection.
- Aren't AOT/trim-safe out of the box.
- Give you no compile-time feedback when a type can't be populated (e.g. no parameterless constructor).
AutoTestData generates a plain, debuggable {Type}Builder class per [AutoBuilder] type, at build time. You can set a breakpoint in it, read it, and it fails the build (not the test run) if your type can't be populated.
Usage
using AutoTestData;
[AutoBuilder]
public partial class Person
{
public string Name { get; set; } = "";
public int Age { get; set; }
public Guid Id { get; set; }
public DateTime CreatedAt { get; set; }
public Status Status { get; set; }
}
public enum Status { Pending, Active, Archived }
Generates a PersonBuilder with a fluent API:
// Every property gets a unique, non-default fake value automatically.
var person = new PersonBuilder().Build();
// Override only what your test cares about.
var ada = new PersonBuilder()
.WithName("Ada Lovelace")
.WithAge(36)
.Build();
Requirements
- The type must be
partial. - The type must have a public parameterless constructor (plain POCOs — positional records are not yet supported, see Roadmap).
- Only public settable (
get; set;orget; init;) properties are populated; unsupported property types are silently left at their default value (no compile error).
Supported types (v1.0.0)
string, int, long, short, byte, double, float, decimal, bool, Guid, DateTime, DateTimeOffset, enum, and the nullable (T?) form of any of the above.
Diagnostics
| ID | Description |
|---|---|
ATD001 |
[AutoBuilder] type is not declared partial. |
ATD002 |
[AutoBuilder] type has no accessible public parameterless constructor. |
ATD003 |
[AutoBuilder] type has no public settable properties of a supported type — no builder generated. |
Roadmap
- Nested
[AutoBuilder]object graphs. - Collections (
List<T>, arrays) of supported/nested types. - Positional record support.
[Fake(...)]per-property customization (min/max ranges, string patterns, seeded values).
Install
dotnet add package Swevo.AutoTestData
License
MIT — see LICENSE.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 |
|---|---|---|
| 1.0.0 | 91 | 7/10/2026 |
1.0.0: Initial release. [AutoBuilder] generates a fluent {Type}Builder with unique fake values for string, int, long, short, byte, double, float, decimal, bool, Guid, DateTime, DateTimeOffset, enum, and their nullable equivalents.