Soenneker.Utils.AutoBogus 2.1.100

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.AutoBogus --version 2.1.100
NuGet\Install-Package Soenneker.Utils.AutoBogus -Version 2.1.100
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="Soenneker.Utils.AutoBogus" Version="2.1.100" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.AutoBogus --version 2.1.100
#r "nuget: Soenneker.Utils.AutoBogus, 2.1.100"
#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.
// Install Soenneker.Utils.AutoBogus as a Cake Addin
#addin nuget:?package=Soenneker.Utils.AutoBogus&version=2.1.100

// Install Soenneker.Utils.AutoBogus as a Cake Tool
#tool nuget:?package=Soenneker.Utils.AutoBogus&version=2.1.100

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.AutoBogus

The .NET Autogenerator

This project is an automatic creator and populator for the fake data generator Bogus. It's a replacement for the abandoned AutoBogus library.

The goals are to be fast, and support the latest types in .NET. It uses the fastest .NET Reflection cache: soenneker.reflection.cache

.NET 6+ is supported.

Installation

dotnet add package Soenneker.Utils.AutoBogus

Usage

  • Create an AutoFaker instance:
var optionalConfig = new AutoFakerConfig();
var autoFaker = new AutoFaker(optionalConfig);
  • Call Generate<>() on any type you want:
var randomWord = autoFaker.Generate<string>();
var dictionary = autoFaker.Generate<Dictionary<int, string>>();
var order = autoFaker.Generate<Order>();
  • Set a faker, configuration, rules, etc:
autoFaker.Config.Faker = new Faker("de");
autoFaker.Config.RepeatCount = 3;
...

AutoFakerOverride can be used for type customization:

public class OrderOverride : AutoFakerOverride<Order>
{
    public override void Generate(AutoFakerOverrideContext context)
    {
        var target = (context.Instance as Order)!;
        target.Id = 123;
        
        // Faker is available
        target.Name = context.Faker.Random.Word();

        // AutoFaker is also available
        target.Customer = context.AutoFaker.Generate<Customer>();
     }
}

Then just add AutoFakerOverride to the AutoFaker.Config instance:

autoFaker.Config.Overrides = new List<AutoFakerGeneratorOverride>();
autoFaker.Config.Overrides.Add(new OrderOverride());

Tips

  • ⚠️ Instantiating a Bogus Faker takes a substantial amount of time (almost 1ms). An instance of AutoFaker will create one Faker. Thus, it's recommended that a single instance be used if possible.
  • AutoFaker.GenerateStatic<>() is available, but should be avoided (as it creates a new AutoFaker/Faker on each call).

Notes

  • This is a work in progress. Contribution is welcomed.

Benchmarks

Soenneker.Utils.AutoBogus

Method Mean Error StdDev
Generate_int 81.44 ns 1.603 ns 1.499 ns
Generate_string 249.01 ns 2.095 ns 1.959 ns
Generate_complex 6,949.16 ns 57.973 ns 54.228 ns

AutoBogus

Method Mean Error StdDev
Generate_int 1.17 ms 0.033 ms 0.026 ms
Generate_complex 10.91 ms 0.181 ms 0.236 ms

Bogus

Method Mean Error StdDev
Bogus_int 19.58 ns 0.150 ns 0.133 ns
Bogus_string 172.25 ns 2.510 ns 2.347 ns
Bogus_ctor 717,799.56 ns 10,086.875 ns 9,435.269 ns
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Soenneker.Utils.AutoBogus:

Package Downloads
Soenneker.Tests.Unit The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A base test providing faker and autofaker capabilities

Soenneker.Fixtures.Unit The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A base xUnit fixture providing injectable log output, DI mechanisms like IServiceCollection and ServiceProvider, and AutoFaker/Faker for generating test data.

Soenneker.AutoFaker.Overrides.IdNamePair The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

An AutoFaker (AutoBogus) override for the DTO IdNamePair

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.237 3,980 6/21/2024
2.1.236 3,465 6/15/2024
2.1.235 1,571 6/15/2024
2.1.234 6,529 6/1/2024
2.1.233 288 6/1/2024
2.1.232 71 6/1/2024
2.1.231 2,503 6/1/2024
2.1.230 2,915 5/31/2024
2.1.229 2,505 5/29/2024
2.1.228 69 5/29/2024
2.1.227 2,835 5/28/2024
2.1.226 58 5/28/2024
2.1.225 1,956 5/27/2024
2.1.224 68 5/27/2024
2.1.223 3,833 5/26/2024
2.1.221 2,509 5/26/2024
2.1.220 66 5/26/2024
2.1.219 1,723 5/25/2024
2.1.218 62 5/25/2024
2.1.215 847 5/25/2024
2.1.214 69 5/25/2024
2.1.213 2,658 5/25/2024
2.1.212 65 5/25/2024
2.1.211 65 5/25/2024
2.1.210 93 5/25/2024
2.1.208 7,716 5/23/2024
2.1.207 133 5/23/2024
2.1.206 70 5/23/2024
2.1.205 1,247 5/23/2024
2.1.204 72 5/23/2024
2.1.203 1,290 5/22/2024
2.1.202 78 5/22/2024
2.1.201 70 5/22/2024
2.1.200 69 5/22/2024
2.1.199 2,358 5/22/2024
2.1.197 565 5/22/2024
2.1.196 4,542 5/17/2024
2.1.195 1,753 5/17/2024
2.1.194 5,454 5/14/2024
2.1.193 79 5/14/2024
2.1.192 3,157 5/12/2024
2.1.191 5,172 4/29/2024
2.1.190 97 4/29/2024
2.1.189 88 4/29/2024
2.1.188 457 4/29/2024
2.1.187 76 4/29/2024
2.1.186 3,063 4/28/2024
2.1.185 89 4/28/2024
2.1.184 2,060 4/28/2024
2.1.183 806 4/28/2024
2.1.182 2,284 4/28/2024
2.1.181 75 4/28/2024
2.1.180 77 4/28/2024
2.1.179 1,538 4/28/2024
2.1.178 90 4/27/2024
2.1.177 75 4/27/2024
2.1.176 5,841 4/19/2024
2.1.175 2,086 4/18/2024
2.1.174 4,048 4/12/2024
2.1.173 1,654 4/12/2024
2.1.172 531 4/12/2024
2.1.171 395 4/12/2024
2.1.170 74 4/12/2024
2.1.169 68 4/12/2024
2.1.168 1,998 4/12/2024
2.1.167 78 4/12/2024
2.1.166 72 4/12/2024
2.1.165 74 4/12/2024
2.1.164 78 4/12/2024
2.1.163 5,892 4/9/2024
2.1.162 3,180 4/1/2024
2.1.161 84 4/1/2024
2.1.160 5,634 3/25/2024
2.1.159 73 3/25/2024
2.1.158 2,265 3/20/2024
2.1.157 2,072 3/19/2024
2.1.156 1,178 3/19/2024
2.1.155 3,282 3/15/2024
2.1.154 2,064 3/13/2024
2.1.153 843 3/13/2024
2.1.152 342 3/13/2024
2.1.151 91 3/13/2024
2.1.150 82 3/13/2024
2.1.149 90 3/13/2024
2.1.148 101 3/13/2024
2.1.147 2,656 3/12/2024
2.1.146 3,384 3/11/2024
2.1.145 86 3/11/2024
2.1.144 1,211 3/11/2024
2.1.143 1,694 3/9/2024
2.1.142 1,904 3/8/2024
2.1.141 1,242 3/8/2024
2.1.140 2,789 3/6/2024
2.1.139 89 3/6/2024
2.1.138 1,925 3/4/2024
2.1.137 78 3/4/2024
2.1.136 2,652 3/2/2024
2.1.135 1,167 3/2/2024
2.1.134 82 3/2/2024
2.1.133 1,475 3/2/2024
2.1.132 767 3/2/2024
2.1.131 1,735 2/29/2024
2.1.130 1,472 2/29/2024
2.1.129 1,739 2/26/2024
2.1.128 1,543 2/25/2024
2.1.127 78 2/25/2024
2.1.126 2,116 2/23/2024
2.1.125 1,631 2/22/2024
2.1.124 1,064 2/21/2024
2.1.123 1,380 2/21/2024
2.1.122 314 2/21/2024
2.1.121 298 2/21/2024
2.1.120 83 2/21/2024
2.1.119 1,287 2/21/2024
2.1.118 85 2/21/2024
2.1.117 83 2/21/2024
2.1.116 619 2/21/2024
2.1.115 982 2/21/2024
2.1.114 85 2/21/2024
2.1.113 88 2/21/2024
2.1.112 83 2/21/2024
2.1.111 780 2/21/2024
2.1.110 83 2/21/2024
2.1.109 2,589 2/20/2024
2.1.108 80 2/20/2024
2.1.107 2,575 2/19/2024
2.1.106 251 2/19/2024
2.1.104 2,815 2/17/2024
2.1.103 1,382 2/16/2024
2.1.102 73 2/16/2024
2.1.101 698 2/16/2024
2.1.100 1,149 2/16/2024
2.1.99 77 2/16/2024
2.1.98 73 2/16/2024
2.1.97 685 2/16/2024
2.1.96 72 2/16/2024
2.1.95 71 2/16/2024
2.1.94 1,395 2/16/2024
2.1.93 74 2/16/2024
2.1.92 2,060 2/13/2024
2.1.91 2,053 2/13/2024
2.1.90 775 2/13/2024
2.1.89 81 2/13/2024
2.1.88 644 2/13/2024
2.1.87 2,046 2/11/2024
2.1.86 783 2/11/2024
2.1.85 93 2/11/2024
2.1.84 1,471 2/11/2024
2.1.83 86 2/11/2024
2.1.82 1,088 2/11/2024
2.1.81 87 2/11/2024
2.1.80 90 2/11/2024
2.1.79 88 2/11/2024
2.1.78 85 2/11/2024
2.1.76 2,380 2/9/2024
2.1.75 85 2/9/2024
2.1.74 1,467 2/9/2024
2.1.73 89 2/9/2024
2.1.72 946 2/8/2024
2.1.71 85 2/8/2024
2.1.70 83 2/8/2024
2.1.69 443 2/8/2024
2.1.68 1,103 2/8/2024
2.1.67 89 2/8/2024
2.1.66 84 2/8/2024
2.1.65 1,101 2/8/2024
2.1.64 83 2/8/2024
2.1.63 772 2/8/2024
2.1.62 2,079 2/7/2024
2.1.61 1,055 2/6/2024
2.1.60 91 2/6/2024
2.1.59 1,352 2/6/2024
2.1.58 94 2/6/2024
2.1.57 852 2/6/2024
2.1.54 88 2/5/2024
2.1.53 86 2/5/2024
2.1.52 2,822 2/4/2024
2.1.51 1,259 2/2/2024
2.1.49 78 2/1/2024
2.1.48 1,663 1/31/2024
2.1.47 1,335 1/29/2024
2.1.46 1,330 1/29/2024
2.1.45 621 1/29/2024
2.1.44 828 1/28/2024
2.1.43 78 1/28/2024
2.1.42 855 1/28/2024
2.1.41 76 1/28/2024
2.1.40 80 1/28/2024
2.1.39 702 1/28/2024
2.1.38 910 1/28/2024
2.1.37 684 1/28/2024
2.1.36 80 1/28/2024
2.1.35 76 1/28/2024
2.1.34 79 1/28/2024
2.1.33 901 1/27/2024
2.1.31 295 1/27/2024
2.1.30 1,022 1/27/2024
2.1.29 939 1/27/2024
2.1.27 506 1/27/2024
2.1.26 996 1/27/2024
2.1.25 689 1/26/2024
2.1.24 74 1/26/2024
2.1.23 77 1/26/2024
2.1.22 78 1/26/2024
2.1.21 662 1/26/2024
2.1.20 649 1/26/2024
2.1.19 700 1/26/2024
2.1.18 696 1/26/2024
2.1.17 779 1/26/2024
2.1.16 783 1/26/2024
2.1.15 297 1/25/2024
2.1.14 852 1/25/2024
2.1.13 844 1/25/2024
2.1.12 80 1/25/2024
2.1.11 758 1/25/2024
2.1.10 714 1/25/2024
2.1.9 773 1/25/2024
2.1.7 5,139 1/15/2024
2.1.6 1,143 1/14/2024
2.1.5 1,419 1/14/2024
2.1.4 1,343 1/13/2024
2.1.3 1,368 1/5/2024
2.1.2 113 1/2/2024
2.1.1 124 12/29/2023