Soenneker.Utils.AutoBogus 2.1.124

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.124                
NuGet\Install-Package Soenneker.Utils.AutoBogus -Version 2.1.124                
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.124" />                
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.124                
#r "nuget: Soenneker.Utils.AutoBogus, 2.1.124"                
#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.124

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

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>();
  • It's also possible to generate types via an argument:
var randomWord = autoFaker.Generate(typeof(string));
  • 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 79.40 ns 0.635 ns 0.563 ns
Generate_string 241.35 ns 3.553 ns 3.324 ns
Generate_complex 6,782.34 ns 43.811 ns 38.837 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

A base test providing faker and autofaker capabilities

Soenneker.Fixtures.Unit

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

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.336 2,818 9/17/2024
2.1.335 36 9/17/2024
2.1.334 3,090 9/17/2024
2.1.333 2,018 9/17/2024
2.1.332 42 9/17/2024
2.1.331 35 9/17/2024
2.1.330 91 9/17/2024
2.1.328 14,789 9/12/2024
2.1.327 2,538 9/11/2024
2.1.326 860 9/11/2024
2.1.325 2,595 9/11/2024
2.1.324 72 9/11/2024
2.1.323 6,778 9/10/2024
2.1.322 1,177 9/10/2024
2.1.320 2,051 9/9/2024
2.1.319 1,285 9/9/2024
2.1.318 1,752 9/9/2024
2.1.317 4,928 9/9/2024
2.1.316 69 9/9/2024
2.1.315 2,722 9/9/2024
2.1.314 3,707 9/6/2024
2.1.313 2,874 9/6/2024
2.1.312 1,984 9/5/2024
2.1.311 72 9/5/2024
2.1.310 356 9/5/2024
2.1.309 64 9/5/2024
2.1.308 1,585 9/5/2024
2.1.307 69 9/5/2024
2.1.306 80 9/5/2024
2.1.305 68 9/5/2024
2.1.304 71 9/5/2024
2.1.303 80 9/5/2024
2.1.302 6,009 9/4/2024
2.1.301 1,004 9/4/2024
2.1.300 4,223 9/3/2024
2.1.299 2,550 9/3/2024
2.1.298 2,965 9/3/2024
2.1.297 405 9/2/2024
2.1.296 4,129 8/29/2024
2.1.295 3,140 8/25/2024
2.1.294 4,192 8/21/2024
2.1.293 79 8/21/2024
2.1.292 81 8/21/2024
2.1.291 903 8/20/2024
2.1.290 94 8/20/2024
2.1.289 837 8/20/2024
2.1.288 96 8/20/2024
2.1.287 1,859 8/20/2024
2.1.286 80 8/20/2024
2.1.285 81 8/20/2024
2.1.284 5,897 8/19/2024
2.1.283 5,946 8/13/2024
2.1.282 7,780 8/6/2024
2.1.281 952 8/6/2024
2.1.280 3,710 8/1/2024
2.1.279 2,858 7/31/2024
2.1.278 4,515 7/25/2024
2.1.277 50 7/25/2024
2.1.276 1,827 7/24/2024
2.1.275 610 7/24/2024
2.1.274 8,672 7/19/2024
2.1.273 3,513 7/14/2024
2.1.272 1,816 7/14/2024
2.1.271 4,766 7/10/2024
2.1.270 2,523 7/10/2024
2.1.269 868 7/10/2024
2.1.268 72 7/10/2024
2.1.267 387 7/10/2024
2.1.266 585 7/10/2024
2.1.265 76 7/10/2024
2.1.264 1,607 7/9/2024
2.1.261 141 7/9/2024
2.1.260 4,593 7/9/2024
2.1.259 3,182 7/9/2024
2.1.258 73 7/9/2024
2.1.257 645 7/9/2024
2.1.256 77 7/9/2024
2.1.255 1,677 7/9/2024
2.1.254 68 7/9/2024
2.1.253 2,374 7/9/2024
2.1.252 82 7/9/2024
2.1.251 535 7/9/2024
2.1.249 86 7/8/2024
2.1.248 86 7/8/2024
2.1.247 80 7/8/2024
2.1.246 592 7/8/2024
2.1.245 87 7/8/2024
2.1.244 80 7/8/2024
2.1.243 6,018 7/7/2024
2.1.242 1,047 7/7/2024
2.1.241 1,002 7/7/2024
2.1.240 570 7/7/2024
2.1.239 8,253 7/3/2024
2.1.238 806 7/3/2024
2.1.237 7,514 6/21/2024
2.1.236 3,619 6/15/2024
2.1.235 1,585 6/15/2024
2.1.234 7,621 6/1/2024
2.1.233 300 6/1/2024
2.1.232 82 6/1/2024
2.1.231 2,515 6/1/2024
2.1.230 2,927 5/31/2024
2.1.229 2,684 5/29/2024
2.1.228 80 5/29/2024
2.1.227 2,885 5/28/2024
2.1.226 69 5/28/2024
2.1.225 1,970 5/27/2024
2.1.224 79 5/27/2024
2.1.223 3,845 5/26/2024
2.1.221 2,521 5/26/2024
2.1.220 77 5/26/2024
2.1.219 1,735 5/25/2024
2.1.218 73 5/25/2024
2.1.215 859 5/25/2024
2.1.214 80 5/25/2024
2.1.213 2,672 5/25/2024
2.1.212 76 5/25/2024
2.1.211 76 5/25/2024
2.1.210 106 5/25/2024
2.1.208 11,741 5/23/2024
2.1.207 142 5/23/2024
2.1.206 81 5/23/2024
2.1.205 1,259 5/23/2024
2.1.204 83 5/23/2024
2.1.203 1,303 5/22/2024
2.1.202 89 5/22/2024
2.1.201 81 5/22/2024
2.1.200 80 5/22/2024
2.1.199 2,370 5/22/2024
2.1.197 577 5/22/2024
2.1.196 4,634 5/17/2024
2.1.195 1,764 5/17/2024
2.1.194 5,466 5/14/2024
2.1.193 94 5/14/2024
2.1.192 3,182 5/12/2024
2.1.191 7,074 4/29/2024
2.1.190 112 4/29/2024
2.1.189 105 4/29/2024
2.1.188 466 4/29/2024
2.1.187 84 4/29/2024
2.1.186 3,072 4/28/2024
2.1.185 97 4/28/2024
2.1.184 2,068 4/28/2024
2.1.183 819 4/28/2024
2.1.182 2,292 4/28/2024
2.1.181 81 4/28/2024
2.1.180 84 4/28/2024
2.1.179 1,545 4/28/2024
2.1.178 106 4/27/2024
2.1.177 83 4/27/2024
2.1.176 5,851 4/19/2024
2.1.175 2,103 4/18/2024
2.1.174 4,163 4/12/2024
2.1.173 1,665 4/12/2024
2.1.172 547 4/12/2024
2.1.171 411 4/12/2024
2.1.170 84 4/12/2024
2.1.169 84 4/12/2024
2.1.168 2,014 4/12/2024
2.1.167 92 4/12/2024
2.1.166 89 4/12/2024
2.1.165 82 4/12/2024
2.1.164 87 4/12/2024
2.1.163 5,942 4/9/2024
2.1.162 3,225 4/1/2024
2.1.161 94 4/1/2024
2.1.160 6,591 3/25/2024
2.1.159 82 3/25/2024
2.1.158 2,278 3/20/2024
2.1.157 2,080 3/19/2024
2.1.156 1,186 3/19/2024
2.1.155 3,290 3/15/2024
2.1.154 2,074 3/13/2024
2.1.153 852 3/13/2024
2.1.152 352 3/13/2024
2.1.151 101 3/13/2024
2.1.150 92 3/13/2024
2.1.149 102 3/13/2024
2.1.148 113 3/13/2024
2.1.147 2,666 3/12/2024
2.1.146 3,400 3/11/2024
2.1.145 96 3/11/2024
2.1.144 1,229 3/11/2024
2.1.143 1,706 3/9/2024
2.1.142 1,916 3/8/2024
2.1.141 1,252 3/8/2024
2.1.140 2,800 3/6/2024
2.1.139 105 3/6/2024
2.1.138 1,938 3/4/2024
2.1.137 91 3/4/2024
2.1.136 2,663 3/2/2024
2.1.135 1,180 3/2/2024
2.1.134 95 3/2/2024
2.1.133 1,489 3/2/2024
2.1.132 782 3/2/2024
2.1.131 1,749 2/29/2024
2.1.130 1,480 2/29/2024
2.1.129 1,749 2/26/2024
2.1.128 1,552 2/25/2024
2.1.127 87 2/25/2024
2.1.126 2,125 2/23/2024
2.1.125 1,750 2/22/2024
2.1.124 1,074 2/21/2024
2.1.123 1,390 2/21/2024
2.1.122 329 2/21/2024
2.1.121 307 2/21/2024
2.1.120 93 2/21/2024
2.1.119 1,297 2/21/2024
2.1.118 95 2/21/2024
2.1.117 93 2/21/2024
2.1.116 629 2/21/2024
2.1.115 994 2/21/2024
2.1.114 96 2/21/2024
2.1.113 99 2/21/2024
2.1.112 99 2/21/2024
2.1.111 790 2/21/2024
2.1.110 94 2/21/2024
2.1.109 2,599 2/20/2024
2.1.108 91 2/20/2024
2.1.107 2,585 2/19/2024
2.1.106 267 2/19/2024
2.1.104 2,832 2/17/2024
2.1.103 1,393 2/16/2024
2.1.102 83 2/16/2024
2.1.101 710 2/16/2024
2.1.100 1,159 2/16/2024
2.1.99 87 2/16/2024
2.1.98 83 2/16/2024
2.1.97 695 2/16/2024
2.1.96 87 2/16/2024
2.1.95 80 2/16/2024
2.1.94 1,407 2/16/2024
2.1.93 86 2/16/2024
2.1.92 2,070 2/13/2024
2.1.91 2,065 2/13/2024
2.1.90 785 2/13/2024
2.1.89 91 2/13/2024
2.1.88 660 2/13/2024
2.1.87 2,056 2/11/2024
2.1.86 793 2/11/2024
2.1.85 103 2/11/2024
2.1.84 1,482 2/11/2024
2.1.83 98 2/11/2024
2.1.82 1,104 2/11/2024
2.1.81 97 2/11/2024
2.1.80 100 2/11/2024
2.1.79 98 2/11/2024
2.1.78 95 2/11/2024
2.1.76 2,390 2/9/2024
2.1.75 96 2/9/2024
2.1.74 1,479 2/9/2024
2.1.73 107 2/9/2024
2.1.72 958 2/8/2024
2.1.71 98 2/8/2024
2.1.70 95 2/8/2024
2.1.69 454 2/8/2024
2.1.68 1,114 2/8/2024
2.1.67 100 2/8/2024
2.1.66 95 2/8/2024
2.1.65 1,109 2/8/2024
2.1.64 91 2/8/2024
2.1.63 781 2/8/2024
2.1.62 2,089 2/7/2024
2.1.61 1,066 2/6/2024
2.1.60 105 2/6/2024
2.1.59 1,363 2/6/2024
2.1.58 104 2/6/2024
2.1.57 860 2/6/2024
2.1.54 102 2/5/2024
2.1.53 100 2/5/2024
2.1.52 2,838 2/4/2024
2.1.51 1,282 2/2/2024
2.1.49 90 2/1/2024
2.1.48 1,673 1/31/2024
2.1.47 1,345 1/29/2024
2.1.46 1,340 1/29/2024
2.1.45 632 1/29/2024
2.1.44 838 1/28/2024
2.1.43 88 1/28/2024
2.1.42 864 1/28/2024
2.1.41 87 1/28/2024
2.1.40 90 1/28/2024
2.1.39 711 1/28/2024
2.1.38 919 1/28/2024
2.1.37 695 1/28/2024
2.1.36 89 1/28/2024
2.1.35 87 1/28/2024
2.1.34 88 1/28/2024
2.1.33 911 1/27/2024
2.1.31 304 1/27/2024
2.1.30 1,032 1/27/2024
2.1.29 948 1/27/2024
2.1.27 516 1/27/2024
2.1.26 1,006 1/27/2024
2.1.25 698 1/26/2024
2.1.24 84 1/26/2024
2.1.23 86 1/26/2024
2.1.22 90 1/26/2024
2.1.21 671 1/26/2024
2.1.20 659 1/26/2024
2.1.19 709 1/26/2024
2.1.18 706 1/26/2024
2.1.17 790 1/26/2024
2.1.16 792 1/26/2024
2.1.15 306 1/25/2024
2.1.14 862 1/25/2024
2.1.13 853 1/25/2024
2.1.12 90 1/25/2024
2.1.11 767 1/25/2024
2.1.10 727 1/25/2024
2.1.9 790 1/25/2024
2.1.7 5,150 1/15/2024
2.1.6 1,156 1/14/2024
2.1.5 1,430 1/14/2024
2.1.4 1,356 1/13/2024
2.1.3 1,379 1/5/2024
2.1.2 122 1/2/2024
2.1.1 139 12/29/2023