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
                    
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="Swevo.AutoTestData" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Swevo.AutoTestData" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Swevo.AutoTestData" />
                    
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 Swevo.AutoTestData --version 1.0.0
                    
#r "nuget: Swevo.AutoTestData, 1.0.0"
                    
#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 Swevo.AutoTestData@1.0.0
                    
#: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=Swevo.AutoTestData&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Swevo.AutoTestData&version=1.0.0
                    
Install as a Cake Tool

Swevo.AutoTestData

NuGet License: MIT

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; or get; 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.

There are no supported framework assets in this package.

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.