Soenneker.Utils.AutoBogus 2.1.264

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

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

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 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

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();

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 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 (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.Moq

An AutoFakerBinder for interfaces and abstract objects using Moq

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.426 6 11/30/2024
3.0.425 2,655 11/29/2024
3.0.424 4,402 11/20/2024
3.0.422 4,009 11/20/2024
3.0.420 930 11/20/2024
3.0.419 5,036 11/19/2024
3.0.418 70 11/19/2024
3.0.417 134 11/19/2024
3.0.416 63 11/19/2024
3.0.415 663 11/19/2024
3.0.414 2,124 11/19/2024
3.0.413 66 11/19/2024
3.0.412 61 11/19/2024
3.0.411 67 11/19/2024
3.0.410 10,850 11/14/2024
3.0.409 3,643 11/14/2024
3.0.408 64 11/14/2024
3.0.407 3,650 11/14/2024
3.0.406 3,228 11/14/2024
3.0.405 66 11/14/2024
3.0.404 1,190 11/14/2024
3.0.403 68 11/14/2024
3.0.402 514 11/14/2024
3.0.401 127 11/14/2024
3.0.400 64 11/14/2024
3.0.399 71 11/14/2024
2.1.398 1,107 11/13/2024
2.1.397 8,806 11/12/2024
2.1.396 3,286 11/12/2024
2.1.395 5,434 11/9/2024
2.1.394 1,619 11/8/2024
2.1.393 794 11/8/2024
2.1.392 2,146 11/8/2024
2.1.391 1,052 11/8/2024
2.1.390 3,878 11/8/2024
2.1.389 3,127 11/8/2024
2.1.388 6,683 10/31/2024
2.1.387 5,386 10/29/2024
2.1.386 2,898 10/28/2024
2.1.385 6,145 10/26/2024
2.1.383 5,677 10/22/2024
2.1.382 1,454 10/22/2024
2.1.381 5,724 10/17/2024
2.1.380 4,395 10/14/2024
2.1.379 356 10/14/2024
2.1.378 3,906 10/11/2024
2.1.377 616 10/11/2024
2.1.376 5,841 10/8/2024
2.1.375 4,740 10/8/2024
2.1.374 6,952 10/3/2024
2.1.373 71 10/3/2024
2.1.372 70 10/3/2024
2.1.371 1,122 10/3/2024
2.1.370 1,740 10/3/2024
2.1.369 5,545 10/2/2024
2.1.368 81 10/2/2024
2.1.367 5,569 10/1/2024
2.1.366 1,460 10/1/2024
2.1.365 4,698 9/29/2024
2.1.364 1,158 9/29/2024
2.1.363 82 9/29/2024
2.1.362 4,834 9/27/2024
2.1.361 80 9/27/2024
2.1.360 178 9/27/2024
2.1.359 75 9/27/2024
2.1.358 2,591 9/27/2024
2.1.357 80 9/27/2024
2.1.356 75 9/27/2024
2.1.355 3,605 9/27/2024
2.1.354 3,861 9/26/2024
2.1.353 141 9/26/2024
2.1.351 4,867 9/26/2024
2.1.350 2,184 9/25/2024
2.1.349 83 9/25/2024
2.1.348 85 9/25/2024
2.1.347 4,371 9/23/2024
2.1.346 1,986 9/23/2024
2.1.345 1,808 9/23/2024
2.1.344 86 9/23/2024
2.1.343 119 9/23/2024
2.1.342 3,658 9/23/2024
2.1.341 81 9/23/2024
2.1.340 89 9/23/2024
2.1.339 1,350 9/23/2024
2.1.338 80 9/23/2024
2.1.337 1,403 9/22/2024
2.1.336 6,890 9/17/2024
2.1.335 87 9/17/2024
2.1.334 3,223 9/17/2024
2.1.333 2,160 9/17/2024
2.1.332 91 9/17/2024
2.1.331 83 9/17/2024
2.1.330 153 9/17/2024
2.1.328 15,502 9/12/2024
2.1.327 2,614 9/11/2024
2.1.326 899 9/11/2024
2.1.325 2,658 9/11/2024
2.1.324 100 9/11/2024
2.1.323 6,942 9/10/2024
2.1.322 1,219 9/10/2024
2.1.320 2,112 9/9/2024
2.1.319 1,328 9/9/2024
2.1.318 1,808 9/9/2024
2.1.317 4,993 9/9/2024
2.1.316 95 9/9/2024
2.1.315 2,792 9/9/2024
2.1.314 3,779 9/6/2024
2.1.313 2,938 9/6/2024
2.1.312 2,035 9/5/2024
2.1.311 103 9/5/2024
2.1.310 399 9/5/2024
2.1.309 91 9/5/2024
2.1.308 1,650 9/5/2024
2.1.307 95 9/5/2024
2.1.306 105 9/5/2024
2.1.305 96 9/5/2024
2.1.304 107 9/5/2024
2.1.303 105 9/5/2024
2.1.302 6,136 9/4/2024
2.1.301 1,044 9/4/2024
2.1.300 4,301 9/3/2024
2.1.299 2,626 9/3/2024
2.1.298 3,020 9/3/2024
2.1.297 444 9/2/2024
2.1.296 4,539 8/29/2024
2.1.295 3,350 8/25/2024
2.1.294 4,307 8/21/2024
2.1.293 102 8/21/2024
2.1.292 103 8/21/2024
2.1.291 947 8/20/2024
2.1.290 117 8/20/2024
2.1.289 872 8/20/2024
2.1.288 117 8/20/2024
2.1.287 1,917 8/20/2024
2.1.286 104 8/20/2024
2.1.285 103 8/20/2024
2.1.284 6,155 8/19/2024
2.1.283 6,105 8/13/2024
2.1.282 8,009 8/6/2024
2.1.281 1,001 8/6/2024
2.1.280 5,111 8/1/2024
2.1.279 2,930 7/31/2024
2.1.278 5,645 7/25/2024
2.1.277 74 7/25/2024
2.1.276 1,888 7/24/2024
2.1.275 655 7/24/2024
2.1.274 9,883 7/19/2024
2.1.273 3,561 7/14/2024
2.1.272 1,865 7/14/2024
2.1.271 4,844 7/10/2024
2.1.270 2,563 7/10/2024
2.1.269 900 7/10/2024
2.1.268 92 7/10/2024
2.1.267 409 7/10/2024
2.1.266 649 7/10/2024
2.1.265 96 7/10/2024
2.1.264 1,636 7/9/2024
2.1.261 175 7/9/2024
2.1.260 4,655 7/9/2024
2.1.259 3,241 7/9/2024
2.1.258 95 7/9/2024
2.1.257 698 7/9/2024
2.1.256 102 7/9/2024
2.1.255 1,720 7/9/2024
2.1.254 92 7/9/2024
2.1.253 2,421 7/9/2024
2.1.252 99 7/9/2024
2.1.251 566 7/9/2024
2.1.249 103 7/8/2024
2.1.248 111 7/8/2024
2.1.247 97 7/8/2024
2.1.246 628 7/8/2024
2.1.245 111 7/8/2024
2.1.244 101 7/8/2024
2.1.243 6,110 7/7/2024
2.1.242 1,081 7/7/2024
2.1.241 1,034 7/7/2024
2.1.240 609 7/7/2024
2.1.239 9,029 7/3/2024
2.1.238 847 7/3/2024
2.1.237 8,322 6/21/2024
2.1.236 3,677 6/15/2024
2.1.235 1,623 6/15/2024
2.1.234 8,215 6/1/2024
2.1.233 339 6/1/2024
2.1.232 101 6/1/2024
2.1.231 2,588 6/1/2024
2.1.230 2,982 5/31/2024
2.1.229 2,760 5/29/2024
2.1.228 100 5/29/2024
2.1.227 2,933 5/28/2024
2.1.226 86 5/28/2024
2.1.225 2,018 5/27/2024
2.1.224 96 5/27/2024
2.1.223 3,902 5/26/2024
2.1.221 2,583 5/26/2024
2.1.220 99 5/26/2024
2.1.219 1,812 5/25/2024
2.1.218 91 5/25/2024
2.1.215 887 5/25/2024
2.1.214 98 5/25/2024
2.1.213 2,720 5/25/2024
2.1.212 96 5/25/2024
2.1.211 95 5/25/2024
2.1.210 128 5/25/2024
2.1.208 15,502 5/23/2024
2.1.207 160 5/23/2024
2.1.206 98 5/23/2024
2.1.205 1,291 5/23/2024
2.1.204 101 5/23/2024
2.1.203 1,342 5/22/2024
2.1.202 112 5/22/2024
2.1.201 100 5/22/2024
2.1.200 100 5/22/2024
2.1.199 2,420 5/22/2024
2.1.197 610 5/22/2024
2.1.196 4,727 5/17/2024
2.1.195 1,800 5/17/2024
2.1.194 5,544 5/14/2024
2.1.193 116 5/14/2024
2.1.192 3,258 5/12/2024
2.1.191 9,315 4/29/2024
2.1.190 134 4/29/2024
2.1.189 124 4/29/2024
2.1.188 493 4/29/2024
2.1.187 102 4/29/2024
2.1.186 3,131 4/28/2024
2.1.185 118 4/28/2024
2.1.184 2,139 4/28/2024
2.1.183 849 4/28/2024
2.1.182 2,336 4/28/2024
2.1.181 96 4/28/2024
2.1.180 99 4/28/2024
2.1.179 1,589 4/28/2024
2.1.178 130 4/27/2024
2.1.177 88 4/27/2024
2.1.176 5,941 4/19/2024
2.1.175 2,154 4/18/2024
2.1.174 4,226 4/12/2024
2.1.173 1,714 4/12/2024
2.1.172 571 4/12/2024
2.1.171 432 4/12/2024
2.1.170 108 4/12/2024
2.1.169 117 4/12/2024
2.1.168 2,070 4/12/2024
2.1.167 112 4/12/2024
2.1.166 125 4/12/2024
2.1.165 99 4/12/2024
2.1.164 92 4/12/2024
2.1.163 6,040 4/9/2024
2.1.162 3,299 4/1/2024
2.1.161 113 4/1/2024
2.1.160 7,172 3/25/2024
2.1.159 101 3/25/2024
2.1.158 2,340 3/20/2024
2.1.157 2,138 3/19/2024
2.1.156 1,229 3/19/2024
2.1.155 3,346 3/15/2024
2.1.154 2,112 3/13/2024
2.1.153 885 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,774 3/12/2024
2.1.146 3,474 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,861 3/6/2024
2.1.139 126 3/6/2024
2.1.138 1,988 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,809 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 1,999 2/22/2024
2.1.124 1,118 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 116 2/21/2024
2.1.117 115 2/21/2024
2.1.116 666 2/21/2024
2.1.115 1,026 2/21/2024
2.1.114 121 2/21/2024
2.1.113 116 2/21/2024
2.1.112 116 2/21/2024
2.1.111 825 2/21/2024
2.1.110 116 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,895 2/17/2024
2.1.103 1,449 2/16/2024
2.1.102 101 2/16/2024
2.1.101 756 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 734 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,137 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,117 2/11/2024
2.1.86 819 2/11/2024
2.1.85 124 2/11/2024
2.1.84 1,540 2/11/2024
2.1.83 116 2/11/2024
2.1.82 1,138 2/11/2024
2.1.81 118 2/11/2024
2.1.80 107 2/11/2024
2.1.79 120 2/11/2024
2.1.78 117 2/11/2024
2.1.76 2,461 2/9/2024
2.1.75 115 2/9/2024
2.1.74 1,507 2/9/2024
2.1.73 125 2/9/2024
2.1.72 988 2/8/2024
2.1.71 121 2/8/2024
2.1.70 116 2/8/2024
2.1.69 487 2/8/2024
2.1.68 1,147 2/8/2024
2.1.67 120 2/8/2024
2.1.66 113 2/8/2024
2.1.65 1,146 2/8/2024
2.1.64 108 2/8/2024
2.1.63 813 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,419 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,712 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 107 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,040 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 99 1/26/2024
2.1.21 700 1/26/2024
2.1.20 677 1/26/2024
2.1.19 745 1/26/2024
2.1.18 735 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 202 12/29/2023