Soenneker.Utils.AutoBogus 3.0.508

Prefix Reserved
dotnet add package Soenneker.Utils.AutoBogus --version 3.0.508                
NuGet\Install-Package Soenneker.Utils.AutoBogus -Version 3.0.508                
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="3.0.508" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.AutoBogus --version 3.0.508                
#r "nuget: Soenneker.Utils.AutoBogus, 3.0.508"                
#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=3.0.508

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

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:

  • Be fast
  • Support the latest types in .NET

It uses the fastest .NET Reflection cache: soenneker.reflection.cache. Bogus updates are automatically integrated.

.NET 8+ 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

This is the recommended way for controlling 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());

AutoFaker<T>

This inherits from Bogus.Faker, and can be used to designate rules specific to the AutoFaker instance.

var autoFaker = new AutoFaker<Order>();
autoFaker.RuleFor(x => x.Id, f => f.Random.Number());
var order = autoFaker.Generate();

Interfaces/Abstracts

The base library does not generate interfaces or abstract objects, but these enable you to generate mocks of them:

Tips

  • ⚠️ Instantiating an AutoFaker takes a non-trivial amount of time because of Bogus Faker initialization (almost 1ms). It's recommended that a single instance be used if possible.
  • AutoFaker.GenerateStatic<T>() is also available, but should be avoided (as it creates a new AutoFaker/Faker on each call).

Notes

  • Some patterns that existed in AutoBogus have been removed due to the complexity and performance impact.
  • This is a work in progress. Contribution is welcomed.

Benchmarks

Soenneker.Utils.AutoBogus - AutoFaker

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

Soenneker.Utils.AutoBogus - AutoFaker<T>

Method Mean Error StdDev
Generate_string 283.6 ns 3.28 ns 3.07 ns
Generate_complex 8,504.0 ns 76.58 ns 67.89 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.70 ns 0.176 ns 0.165 ns
Bogus_string 171.75 ns 2.763 ns 2.585 ns
Bogus_ctor 730,669.06 ns 8,246.622 ns 7,310.416 ns
Product Compatible and additional computed target framework versions.
.NET 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 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 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

Soenneker.Utils.AutoBogus.NSubstitute

An AutoFakerBinder for interfaces and abstract objects using NSubstitute

Soenneker.Utils.AutoBogus.FakeItEasy

An AutoFakerBinder for interfaces and abstract objects using FakeItEasy

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.508 0 12/23/2024
3.0.507 0 12/23/2024
3.0.506 6 12/23/2024
3.0.505 192 12/23/2024
3.0.504 1,008 12/23/2024
3.0.503 34 12/23/2024
3.0.502 2,080 12/22/2024
3.0.501 33 12/22/2024
3.0.500 3,108 12/22/2024
3.0.499 1,045 12/22/2024
3.0.497 2,597 12/22/2024
3.0.495 1,830 12/22/2024
3.0.494 93 12/21/2024
3.0.493 2,945 12/21/2024
3.0.492 35 12/21/2024
3.0.491 326 12/21/2024
3.0.490 35 12/21/2024
3.0.489 783 12/21/2024
3.0.488 3,921 12/21/2024
3.0.487 36 12/21/2024
3.0.486 1,267 12/21/2024
3.0.485 1,353 12/21/2024
3.0.484 38 12/21/2024
3.0.483 677 12/21/2024
3.0.482 31 12/21/2024
3.0.481 4,026 12/20/2024
3.0.480 4,775 12/20/2024
3.0.479 39 12/20/2024
3.0.478 1,945 12/20/2024
3.0.477 39 12/20/2024
3.0.476 294 12/19/2024
3.0.475 3,321 12/19/2024
3.0.474 47 12/19/2024
3.0.473 2,045 12/18/2024
3.0.472 36 12/18/2024
3.0.471 37 12/18/2024
3.0.470 52 12/18/2024
3.0.469 4,013 12/17/2024
3.0.468 1,200 12/17/2024
3.0.467 64 12/17/2024
3.0.466 1,194 12/16/2024
3.0.465 712 12/16/2024
3.0.464 48 12/16/2024
3.0.463 47 12/16/2024
3.0.462 10,465 12/9/2024
3.0.461 2,067 12/9/2024
3.0.460 4,076 12/9/2024
3.0.459 6,489 12/6/2024
3.0.458 2,315 12/6/2024
3.0.457 96 12/6/2024
3.0.456 3,938 12/6/2024
3.0.455 627 12/6/2024
3.0.454 2,448 12/6/2024
3.0.453 2,073 12/6/2024
3.0.452 3,268 12/5/2024
3.0.451 3,733 12/5/2024
3.0.450 5,735 12/5/2024
3.0.449 709 12/5/2024
3.0.448 1,423 12/5/2024
3.0.447 3,255 12/4/2024
3.0.446 72 12/4/2024
3.0.445 1,466 12/4/2024
3.0.444 5,253 12/4/2024
3.0.443 73 12/4/2024
3.0.442 4,063 12/3/2024
3.0.441 232 12/3/2024
3.0.440 1,383 12/3/2024
3.0.439 75 12/3/2024
3.0.438 2,631 12/3/2024
3.0.437 75 12/3/2024
3.0.436 2,374 12/3/2024
3.0.435 74 12/3/2024
3.0.434 2,088 12/3/2024
3.0.433 1,882 12/2/2024
3.0.432 4,995 12/2/2024
3.0.431 68 12/2/2024
3.0.430 2,566 12/1/2024
3.0.429 71 12/1/2024
3.0.428 3,303 12/1/2024
3.0.427 426 12/1/2024
3.0.426 3,818 11/30/2024
3.0.425 3,862 11/29/2024
3.0.424 5,581 11/20/2024
3.0.422 4,154 11/20/2024
3.0.420 936 11/20/2024
3.0.419 5,044 11/19/2024
3.0.418 76 11/19/2024
3.0.417 143 11/19/2024
3.0.416 71 11/19/2024
3.0.415 670 11/19/2024
3.0.414 2,133 11/19/2024
3.0.413 72 11/19/2024
3.0.412 67 11/19/2024
3.0.411 73 11/19/2024
3.0.410 11,113 11/14/2024
3.0.409 3,648 11/14/2024
3.0.408 71 11/14/2024
3.0.407 3,674 11/14/2024
3.0.406 3,239 11/14/2024
3.0.405 75 11/14/2024
3.0.404 1,201 11/14/2024
3.0.403 79 11/14/2024
3.0.402 523 11/14/2024
3.0.401 139 11/14/2024
3.0.400 75 11/14/2024
3.0.399 84 11/14/2024
2.1.398 1,181 11/13/2024
2.1.397 8,872 11/12/2024
2.1.396 3,291 11/12/2024
2.1.395 5,555 11/9/2024
2.1.394 1,635 11/8/2024
2.1.393 799 11/8/2024
2.1.392 2,151 11/8/2024
2.1.391 1,059 11/8/2024
2.1.390 3,883 11/8/2024
2.1.389 3,134 11/8/2024
2.1.388 6,971 10/31/2024
2.1.387 5,485 10/29/2024
2.1.386 2,901 10/28/2024
2.1.385 6,159 10/26/2024
2.1.383 6,729 10/22/2024
2.1.382 1,733 10/22/2024
2.1.381 5,853 10/17/2024
2.1.380 4,582 10/14/2024
2.1.379 358 10/14/2024
2.1.378 3,949 10/11/2024
2.1.377 618 10/11/2024
2.1.376 6,012 10/8/2024
2.1.375 5,235 10/8/2024
2.1.374 7,125 10/3/2024
2.1.373 73 10/3/2024
2.1.372 72 10/3/2024
2.1.371 1,124 10/3/2024
2.1.370 1,744 10/3/2024
2.1.369 6,023 10/2/2024
2.1.368 85 10/2/2024
2.1.367 5,594 10/1/2024
2.1.366 1,462 10/1/2024
2.1.365 4,702 9/29/2024
2.1.364 1,160 9/29/2024
2.1.363 86 9/29/2024
2.1.362 4,840 9/27/2024
2.1.361 82 9/27/2024
2.1.360 180 9/27/2024
2.1.359 79 9/27/2024
2.1.358 2,593 9/27/2024
2.1.357 84 9/27/2024
2.1.356 77 9/27/2024
2.1.355 3,609 9/27/2024
2.1.354 3,863 9/26/2024
2.1.353 143 9/26/2024
2.1.351 4,869 9/26/2024
2.1.350 2,188 9/25/2024
2.1.349 85 9/25/2024
2.1.348 89 9/25/2024
2.1.347 4,380 9/23/2024
2.1.346 1,988 9/23/2024
2.1.345 1,812 9/23/2024
2.1.344 88 9/23/2024
2.1.343 121 9/23/2024
2.1.342 3,660 9/23/2024
2.1.341 83 9/23/2024
2.1.340 91 9/23/2024
2.1.339 1,352 9/23/2024
2.1.338 82 9/23/2024
2.1.337 1,407 9/22/2024
2.1.336 6,906 9/17/2024
2.1.335 89 9/17/2024
2.1.334 3,227 9/17/2024
2.1.333 2,162 9/17/2024
2.1.332 93 9/17/2024
2.1.331 85 9/17/2024
2.1.330 155 9/17/2024
2.1.328 15,533 9/12/2024
2.1.327 2,616 9/11/2024
2.1.326 901 9/11/2024
2.1.325 2,660 9/11/2024
2.1.324 102 9/11/2024
2.1.323 6,951 9/10/2024
2.1.322 1,223 9/10/2024
2.1.320 2,114 9/9/2024
2.1.319 1,330 9/9/2024
2.1.318 1,810 9/9/2024
2.1.317 4,995 9/9/2024
2.1.316 97 9/9/2024
2.1.315 2,798 9/9/2024
2.1.314 3,787 9/6/2024
2.1.313 2,940 9/6/2024
2.1.312 2,037 9/5/2024
2.1.311 105 9/5/2024
2.1.310 401 9/5/2024
2.1.309 95 9/5/2024
2.1.308 1,665 9/5/2024
2.1.307 99 9/5/2024
2.1.306 109 9/5/2024
2.1.305 98 9/5/2024
2.1.304 109 9/5/2024
2.1.303 107 9/5/2024
2.1.302 6,140 9/4/2024
2.1.301 1,047 9/4/2024
2.1.300 4,303 9/3/2024
2.1.299 2,628 9/3/2024
2.1.298 3,022 9/3/2024
2.1.297 446 9/2/2024
2.1.296 4,541 8/29/2024
2.1.295 3,363 8/25/2024
2.1.294 4,317 8/21/2024
2.1.293 108 8/21/2024
2.1.292 105 8/21/2024
2.1.291 949 8/20/2024
2.1.290 121 8/20/2024
2.1.289 874 8/20/2024
2.1.288 119 8/20/2024
2.1.287 1,921 8/20/2024
2.1.286 110 8/20/2024
2.1.285 107 8/20/2024
2.1.284 6,194 8/19/2024
2.1.283 6,112 8/13/2024
2.1.282 8,013 8/6/2024
2.1.281 1,009 8/6/2024
2.1.280 5,572 8/1/2024
2.1.279 2,932 7/31/2024
2.1.278 5,673 7/25/2024
2.1.277 78 7/25/2024
2.1.276 1,890 7/24/2024
2.1.275 659 7/24/2024
2.1.274 10,170 7/19/2024
2.1.273 3,563 7/14/2024
2.1.272 1,867 7/14/2024
2.1.271 4,846 7/10/2024
2.1.270 2,569 7/10/2024
2.1.269 904 7/10/2024
2.1.268 94 7/10/2024
2.1.267 413 7/10/2024
2.1.266 651 7/10/2024
2.1.265 98 7/10/2024
2.1.264 1,638 7/9/2024
2.1.261 177 7/9/2024
2.1.260 4,657 7/9/2024
2.1.259 3,245 7/9/2024
2.1.258 97 7/9/2024
2.1.257 700 7/9/2024
2.1.256 108 7/9/2024
2.1.255 1,724 7/9/2024
2.1.254 100 7/9/2024
2.1.253 2,425 7/9/2024
2.1.252 103 7/9/2024
2.1.251 568 7/9/2024
2.1.249 105 7/8/2024
2.1.248 114 7/8/2024
2.1.247 101 7/8/2024
2.1.246 634 7/8/2024
2.1.245 115 7/8/2024
2.1.244 105 7/8/2024
2.1.243 6,115 7/7/2024
2.1.242 1,084 7/7/2024
2.1.241 1,037 7/7/2024
2.1.240 612 7/7/2024
2.1.239 9,200 7/3/2024
2.1.238 851 7/3/2024
2.1.237 8,606 6/21/2024
2.1.236 3,680 6/15/2024
2.1.235 1,625 6/15/2024
2.1.234 8,327 6/1/2024
2.1.233 341 6/1/2024
2.1.232 103 6/1/2024
2.1.231 2,590 6/1/2024
2.1.230 2,988 5/31/2024
2.1.229 2,768 5/29/2024
2.1.228 106 5/29/2024
2.1.227 2,935 5/28/2024
2.1.226 92 5/28/2024
2.1.225 2,020 5/27/2024
2.1.224 98 5/27/2024
2.1.223 3,904 5/26/2024
2.1.221 2,585 5/26/2024
2.1.220 101 5/26/2024
2.1.219 1,814 5/25/2024
2.1.218 95 5/25/2024
2.1.215 891 5/25/2024
2.1.214 102 5/25/2024
2.1.213 2,724 5/25/2024
2.1.212 100 5/25/2024
2.1.211 97 5/25/2024
2.1.210 132 5/25/2024
2.1.208 16,139 5/23/2024
2.1.207 164 5/23/2024
2.1.206 100 5/23/2024
2.1.205 1,295 5/23/2024
2.1.204 105 5/23/2024
2.1.203 1,344 5/22/2024
2.1.202 116 5/22/2024
2.1.201 102 5/22/2024
2.1.200 102 5/22/2024
2.1.199 2,422 5/22/2024
2.1.197 612 5/22/2024
2.1.196 4,731 5/17/2024
2.1.195 1,802 5/17/2024
2.1.194 5,548 5/14/2024
2.1.193 119 5/14/2024
2.1.192 3,272 5/12/2024
2.1.191 10,146 4/29/2024
2.1.190 136 4/29/2024
2.1.189 124 4/29/2024
2.1.188 493 4/29/2024
2.1.187 104 4/29/2024
2.1.186 3,133 4/28/2024
2.1.185 120 4/28/2024
2.1.184 2,141 4/28/2024
2.1.183 849 4/28/2024
2.1.182 2,338 4/28/2024
2.1.181 98 4/28/2024
2.1.180 101 4/28/2024
2.1.179 1,589 4/28/2024
2.1.178 130 4/27/2024
2.1.177 90 4/27/2024
2.1.176 5,946 4/19/2024
2.1.175 2,156 4/18/2024
2.1.174 4,233 4/12/2024
2.1.173 1,716 4/12/2024
2.1.172 571 4/12/2024
2.1.171 436 4/12/2024
2.1.170 114 4/12/2024
2.1.169 117 4/12/2024
2.1.168 2,074 4/12/2024
2.1.167 114 4/12/2024
2.1.166 127 4/12/2024
2.1.165 105 4/12/2024
2.1.164 94 4/12/2024
2.1.163 6,042 4/9/2024
2.1.162 3,301 4/1/2024
2.1.161 115 4/1/2024
2.1.160 7,273 3/25/2024
2.1.159 103 3/25/2024
2.1.158 2,344 3/20/2024
2.1.157 2,138 3/19/2024
2.1.156 1,229 3/19/2024
2.1.155 3,348 3/15/2024
2.1.154 2,116 3/13/2024
2.1.153 887 3/13/2024
2.1.152 397 3/13/2024
2.1.151 120 3/13/2024
2.1.150 113 3/13/2024
2.1.149 118 3/13/2024
2.1.148 135 3/13/2024
2.1.147 2,776 3/12/2024
2.1.146 3,478 3/11/2024
2.1.145 116 3/11/2024
2.1.144 1,278 3/11/2024
2.1.143 1,757 3/9/2024
2.1.142 1,973 3/8/2024
2.1.141 1,297 3/8/2024
2.1.140 2,863 3/6/2024
2.1.139 126 3/6/2024
2.1.138 1,990 3/4/2024
2.1.137 107 3/4/2024
2.1.136 2,715 3/2/2024
2.1.135 1,227 3/2/2024
2.1.134 114 3/2/2024
2.1.133 1,562 3/2/2024
2.1.132 838 3/2/2024
2.1.131 1,815 2/29/2024
2.1.130 1,543 2/29/2024
2.1.129 1,807 2/26/2024
2.1.128 1,615 2/25/2024
2.1.127 110 2/25/2024
2.1.126 2,223 2/23/2024
2.1.125 2,065 2/22/2024
2.1.124 1,120 2/21/2024
2.1.123 1,441 2/21/2024
2.1.122 348 2/21/2024
2.1.121 359 2/21/2024
2.1.120 116 2/21/2024
2.1.119 1,365 2/21/2024
2.1.118 118 2/21/2024
2.1.117 115 2/21/2024
2.1.116 672 2/21/2024
2.1.115 1,028 2/21/2024
2.1.114 123 2/21/2024
2.1.113 118 2/21/2024
2.1.112 118 2/21/2024
2.1.111 825 2/21/2024
2.1.110 120 2/21/2024
2.1.109 2,675 2/20/2024
2.1.108 111 2/20/2024
2.1.107 2,655 2/19/2024
2.1.106 306 2/19/2024
2.1.104 2,897 2/17/2024
2.1.103 1,449 2/16/2024
2.1.102 101 2/16/2024
2.1.101 758 2/16/2024
2.1.100 1,209 2/16/2024
2.1.99 109 2/16/2024
2.1.98 105 2/16/2024
2.1.97 736 2/16/2024
2.1.96 108 2/16/2024
2.1.95 102 2/16/2024
2.1.94 1,462 2/16/2024
2.1.93 108 2/16/2024
2.1.92 2,139 2/13/2024
2.1.91 2,142 2/13/2024
2.1.90 826 2/13/2024
2.1.89 107 2/13/2024
2.1.88 694 2/13/2024
2.1.87 2,121 2/11/2024
2.1.86 825 2/11/2024
2.1.85 130 2/11/2024
2.1.84 1,548 2/11/2024
2.1.83 122 2/11/2024
2.1.82 1,144 2/11/2024
2.1.81 122 2/11/2024
2.1.80 117 2/11/2024
2.1.79 124 2/11/2024
2.1.78 121 2/11/2024
2.1.76 2,467 2/9/2024
2.1.75 121 2/9/2024
2.1.74 1,511 2/9/2024
2.1.73 131 2/9/2024
2.1.72 992 2/8/2024
2.1.71 125 2/8/2024
2.1.70 120 2/8/2024
2.1.69 492 2/8/2024
2.1.68 1,153 2/8/2024
2.1.67 124 2/8/2024
2.1.66 118 2/8/2024
2.1.65 1,150 2/8/2024
2.1.64 114 2/8/2024
2.1.63 817 2/8/2024
2.1.62 2,138 2/7/2024
2.1.61 1,106 2/6/2024
2.1.60 126 2/6/2024
2.1.59 1,421 2/6/2024
2.1.58 127 2/6/2024
2.1.57 905 2/6/2024
2.1.54 119 2/5/2024
2.1.53 119 2/5/2024
2.1.52 2,898 2/4/2024
2.1.51 1,316 2/2/2024
2.1.49 108 2/1/2024
2.1.48 1,714 1/31/2024
2.1.47 1,381 1/29/2024
2.1.46 1,389 1/29/2024
2.1.45 649 1/29/2024
2.1.44 878 1/28/2024
2.1.43 109 1/28/2024
2.1.42 901 1/28/2024
2.1.41 92 1/28/2024
2.1.40 110 1/28/2024
2.1.39 751 1/28/2024
2.1.38 956 1/28/2024
2.1.37 717 1/28/2024
2.1.36 96 1/28/2024
2.1.35 104 1/28/2024
2.1.34 105 1/28/2024
2.1.33 950 1/27/2024
2.1.31 337 1/27/2024
2.1.30 1,071 1/27/2024
2.1.29 991 1/27/2024
2.1.27 543 1/27/2024
2.1.26 1,042 1/27/2024
2.1.25 751 1/26/2024
2.1.24 106 1/26/2024
2.1.23 110 1/26/2024
2.1.22 101 1/26/2024
2.1.21 700 1/26/2024
2.1.20 681 1/26/2024
2.1.19 745 1/26/2024
2.1.18 737 1/26/2024
2.1.17 830 1/26/2024
2.1.16 814 1/26/2024
2.1.15 334 1/25/2024
2.1.14 901 1/25/2024
2.1.13 883 1/25/2024
2.1.12 106 1/25/2024
2.1.11 802 1/25/2024
2.1.10 774 1/25/2024
2.1.9 826 1/25/2024
2.1.7 5,236 1/15/2024
2.1.6 1,199 1/14/2024
2.1.5 1,472 1/14/2024
2.1.4 1,408 1/13/2024
2.1.3 1,406 1/5/2024
2.1.2 147 1/2/2024
2.1.1 214 12/29/2023