Soenneker.Utils.AutoBogus 2.1.230

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

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

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.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.424 2,514 11/20/2024
3.0.422 3,822 11/20/2024
3.0.420 887 11/20/2024
3.0.419 4,913 11/19/2024
3.0.418 36 11/19/2024
3.0.417 86 11/19/2024
3.0.416 32 11/19/2024
3.0.415 626 11/19/2024
3.0.414 2,071 11/19/2024
3.0.413 35 11/19/2024
3.0.412 33 11/19/2024
3.0.411 33 11/19/2024
3.0.410 10,452 11/14/2024
3.0.409 3,641 11/14/2024
3.0.408 62 11/14/2024
3.0.407 3,648 11/14/2024
3.0.406 3,226 11/14/2024
3.0.405 64 11/14/2024
3.0.404 1,188 11/14/2024
3.0.403 66 11/14/2024
3.0.402 512 11/14/2024
3.0.401 125 11/14/2024
3.0.400 62 11/14/2024
3.0.399 69 11/14/2024
2.1.398 944 11/13/2024
2.1.397 8,773 11/12/2024
2.1.396 3,279 11/12/2024
2.1.395 5,391 11/9/2024
2.1.394 1,617 11/8/2024
2.1.393 792 11/8/2024
2.1.392 2,144 11/8/2024
2.1.391 1,050 11/8/2024
2.1.390 3,876 11/8/2024
2.1.389 3,125 11/8/2024
2.1.388 6,629 10/31/2024
2.1.387 5,325 10/29/2024
2.1.386 2,896 10/28/2024
2.1.385 6,134 10/26/2024
2.1.383 5,407 10/22/2024
2.1.382 1,379 10/22/2024
2.1.381 5,722 10/17/2024
2.1.380 4,339 10/14/2024
2.1.379 354 10/14/2024
2.1.378 3,872 10/11/2024
2.1.377 614 10/11/2024
2.1.376 5,783 10/8/2024
2.1.375 4,672 10/8/2024
2.1.374 6,927 10/3/2024
2.1.373 69 10/3/2024
2.1.372 68 10/3/2024
2.1.371 1,120 10/3/2024
2.1.370 1,738 10/3/2024
2.1.369 5,462 10/2/2024
2.1.368 79 10/2/2024
2.1.367 5,565 10/1/2024
2.1.366 1,458 10/1/2024
2.1.365 4,696 9/29/2024
2.1.364 1,156 9/29/2024
2.1.363 80 9/29/2024
2.1.362 4,832 9/27/2024
2.1.361 78 9/27/2024
2.1.360 176 9/27/2024
2.1.359 73 9/27/2024
2.1.358 2,589 9/27/2024
2.1.357 78 9/27/2024
2.1.356 73 9/27/2024
2.1.355 3,603 9/27/2024
2.1.354 3,859 9/26/2024
2.1.353 139 9/26/2024
2.1.351 4,865 9/26/2024
2.1.350 2,182 9/25/2024
2.1.349 81 9/25/2024
2.1.348 83 9/25/2024
2.1.347 4,369 9/23/2024
2.1.346 1,983 9/23/2024
2.1.345 1,806 9/23/2024
2.1.344 84 9/23/2024
2.1.343 117 9/23/2024
2.1.342 3,656 9/23/2024
2.1.341 79 9/23/2024
2.1.340 87 9/23/2024
2.1.339 1,348 9/23/2024
2.1.338 78 9/23/2024
2.1.337 1,401 9/22/2024
2.1.336 6,872 9/17/2024
2.1.335 85 9/17/2024
2.1.334 3,221 9/17/2024
2.1.333 2,158 9/17/2024
2.1.332 89 9/17/2024
2.1.331 81 9/17/2024
2.1.330 151 9/17/2024
2.1.328 15,489 9/12/2024
2.1.327 2,612 9/11/2024
2.1.326 897 9/11/2024
2.1.325 2,656 9/11/2024
2.1.324 98 9/11/2024
2.1.323 6,926 9/10/2024
2.1.322 1,217 9/10/2024
2.1.320 2,110 9/9/2024
2.1.319 1,326 9/9/2024
2.1.318 1,806 9/9/2024
2.1.317 4,991 9/9/2024
2.1.316 93 9/9/2024
2.1.315 2,790 9/9/2024
2.1.314 3,777 9/6/2024
2.1.313 2,936 9/6/2024
2.1.312 2,033 9/5/2024
2.1.311 101 9/5/2024
2.1.310 397 9/5/2024
2.1.309 89 9/5/2024
2.1.308 1,648 9/5/2024
2.1.307 93 9/5/2024
2.1.306 103 9/5/2024
2.1.305 94 9/5/2024
2.1.304 105 9/5/2024
2.1.303 103 9/5/2024
2.1.302 6,134 9/4/2024
2.1.301 1,042 9/4/2024
2.1.300 4,299 9/3/2024
2.1.299 2,624 9/3/2024
2.1.298 3,018 9/3/2024
2.1.297 442 9/2/2024
2.1.296 4,537 8/29/2024
2.1.295 3,334 8/25/2024
2.1.294 4,305 8/21/2024
2.1.293 100 8/21/2024
2.1.292 101 8/21/2024
2.1.291 945 8/20/2024
2.1.290 115 8/20/2024
2.1.289 870 8/20/2024
2.1.288 115 8/20/2024
2.1.287 1,915 8/20/2024
2.1.286 102 8/20/2024
2.1.285 101 8/20/2024
2.1.284 6,153 8/19/2024
2.1.283 6,103 8/13/2024
2.1.282 8,007 8/6/2024
2.1.281 999 8/6/2024
2.1.280 5,009 8/1/2024
2.1.279 2,928 7/31/2024
2.1.278 5,631 7/25/2024
2.1.277 72 7/25/2024
2.1.276 1,886 7/24/2024
2.1.275 653 7/24/2024
2.1.274 9,833 7/19/2024
2.1.273 3,559 7/14/2024
2.1.272 1,863 7/14/2024
2.1.271 4,842 7/10/2024
2.1.270 2,561 7/10/2024
2.1.269 898 7/10/2024
2.1.268 90 7/10/2024
2.1.267 407 7/10/2024
2.1.266 647 7/10/2024
2.1.265 94 7/10/2024
2.1.264 1,634 7/9/2024
2.1.261 173 7/9/2024
2.1.260 4,653 7/9/2024
2.1.259 3,239 7/9/2024
2.1.258 93 7/9/2024
2.1.257 696 7/9/2024
2.1.256 100 7/9/2024
2.1.255 1,718 7/9/2024
2.1.254 90 7/9/2024
2.1.253 2,419 7/9/2024
2.1.252 97 7/9/2024
2.1.251 564 7/9/2024
2.1.249 101 7/8/2024
2.1.248 109 7/8/2024
2.1.247 95 7/8/2024
2.1.246 626 7/8/2024
2.1.245 109 7/8/2024
2.1.244 99 7/8/2024
2.1.243 6,108 7/7/2024
2.1.242 1,079 7/7/2024
2.1.241 1,032 7/7/2024
2.1.240 607 7/7/2024
2.1.239 8,957 7/3/2024
2.1.238 845 7/3/2024
2.1.237 8,264 6/21/2024
2.1.236 3,675 6/15/2024
2.1.235 1,621 6/15/2024
2.1.234 8,168 6/1/2024
2.1.233 337 6/1/2024
2.1.232 99 6/1/2024
2.1.231 2,586 6/1/2024
2.1.230 2,980 5/31/2024
2.1.229 2,758 5/29/2024
2.1.228 98 5/29/2024
2.1.227 2,931 5/28/2024
2.1.226 84 5/28/2024
2.1.225 2,016 5/27/2024
2.1.224 94 5/27/2024
2.1.223 3,900 5/26/2024
2.1.221 2,581 5/26/2024
2.1.220 97 5/26/2024
2.1.219 1,810 5/25/2024
2.1.218 89 5/25/2024
2.1.215 885 5/25/2024
2.1.214 96 5/25/2024
2.1.213 2,718 5/25/2024
2.1.212 94 5/25/2024
2.1.211 93 5/25/2024
2.1.210 126 5/25/2024
2.1.208 15,348 5/23/2024
2.1.207 158 5/23/2024
2.1.206 96 5/23/2024
2.1.205 1,289 5/23/2024
2.1.204 99 5/23/2024
2.1.203 1,340 5/22/2024
2.1.202 110 5/22/2024
2.1.201 98 5/22/2024
2.1.200 98 5/22/2024
2.1.199 2,418 5/22/2024
2.1.197 608 5/22/2024
2.1.196 4,721 5/17/2024
2.1.195 1,798 5/17/2024
2.1.194 5,542 5/14/2024
2.1.193 114 5/14/2024
2.1.192 3,252 5/12/2024
2.1.191 9,071 4/29/2024
2.1.190 132 4/29/2024
2.1.189 122 4/29/2024
2.1.188 491 4/29/2024
2.1.187 100 4/29/2024
2.1.186 3,129 4/28/2024
2.1.185 116 4/28/2024
2.1.184 2,137 4/28/2024
2.1.183 847 4/28/2024
2.1.182 2,334 4/28/2024
2.1.181 94 4/28/2024
2.1.180 97 4/28/2024
2.1.179 1,587 4/28/2024
2.1.178 128 4/27/2024
2.1.177 86 4/27/2024
2.1.176 5,939 4/19/2024
2.1.175 2,152 4/18/2024
2.1.174 4,224 4/12/2024
2.1.173 1,712 4/12/2024
2.1.172 569 4/12/2024
2.1.171 430 4/12/2024
2.1.170 106 4/12/2024
2.1.169 115 4/12/2024
2.1.168 2,068 4/12/2024
2.1.167 110 4/12/2024
2.1.166 123 4/12/2024
2.1.165 97 4/12/2024
2.1.164 90 4/12/2024
2.1.163 6,038 4/9/2024
2.1.162 3,294 4/1/2024
2.1.161 111 4/1/2024
2.1.160 7,121 3/25/2024
2.1.159 99 3/25/2024
2.1.158 2,338 3/20/2024
2.1.157 2,136 3/19/2024
2.1.156 1,227 3/19/2024
2.1.155 3,344 3/15/2024
2.1.154 2,110 3/13/2024
2.1.153 883 3/13/2024
2.1.152 395 3/13/2024
2.1.151 118 3/13/2024
2.1.150 111 3/13/2024
2.1.149 116 3/13/2024
2.1.148 133 3/13/2024
2.1.147 2,772 3/12/2024
2.1.146 3,472 3/11/2024
2.1.145 114 3/11/2024
2.1.144 1,276 3/11/2024
2.1.143 1,755 3/9/2024
2.1.142 1,971 3/8/2024
2.1.141 1,295 3/8/2024
2.1.140 2,859 3/6/2024
2.1.139 124 3/6/2024
2.1.138 1,986 3/4/2024
2.1.137 105 3/4/2024
2.1.136 2,713 3/2/2024
2.1.135 1,225 3/2/2024
2.1.134 112 3/2/2024
2.1.133 1,560 3/2/2024
2.1.132 836 3/2/2024
2.1.131 1,807 2/29/2024
2.1.130 1,540 2/29/2024
2.1.129 1,804 2/26/2024
2.1.128 1,612 2/25/2024
2.1.127 107 2/25/2024
2.1.126 2,220 2/23/2024
2.1.125 1,984 2/22/2024
2.1.124 1,116 2/21/2024
2.1.123 1,439 2/21/2024
2.1.122 346 2/21/2024
2.1.121 357 2/21/2024
2.1.120 114 2/21/2024
2.1.119 1,363 2/21/2024
2.1.118 114 2/21/2024
2.1.117 113 2/21/2024
2.1.116 664 2/21/2024
2.1.115 1,024 2/21/2024
2.1.114 119 2/21/2024
2.1.113 114 2/21/2024
2.1.112 114 2/21/2024
2.1.111 823 2/21/2024
2.1.110 114 2/21/2024
2.1.109 2,673 2/20/2024
2.1.108 109 2/20/2024
2.1.107 2,653 2/19/2024
2.1.106 304 2/19/2024
2.1.104 2,893 2/17/2024
2.1.103 1,447 2/16/2024
2.1.102 99 2/16/2024
2.1.101 754 2/16/2024
2.1.100 1,207 2/16/2024
2.1.99 107 2/16/2024
2.1.98 103 2/16/2024
2.1.97 732 2/16/2024
2.1.96 106 2/16/2024
2.1.95 100 2/16/2024
2.1.94 1,460 2/16/2024
2.1.93 106 2/16/2024
2.1.92 2,135 2/13/2024
2.1.91 2,140 2/13/2024
2.1.90 824 2/13/2024
2.1.89 105 2/13/2024
2.1.88 692 2/13/2024
2.1.87 2,115 2/11/2024
2.1.86 817 2/11/2024
2.1.85 122 2/11/2024
2.1.84 1,538 2/11/2024
2.1.83 114 2/11/2024
2.1.82 1,136 2/11/2024
2.1.81 116 2/11/2024
2.1.80 105 2/11/2024
2.1.79 118 2/11/2024
2.1.78 115 2/11/2024
2.1.76 2,459 2/9/2024
2.1.75 113 2/9/2024
2.1.74 1,505 2/9/2024
2.1.73 123 2/9/2024
2.1.72 986 2/8/2024
2.1.71 119 2/8/2024
2.1.70 114 2/8/2024
2.1.69 485 2/8/2024
2.1.68 1,145 2/8/2024
2.1.67 118 2/8/2024
2.1.66 111 2/8/2024
2.1.65 1,144 2/8/2024
2.1.64 106 2/8/2024
2.1.63 811 2/8/2024
2.1.62 2,134 2/7/2024
2.1.61 1,104 2/6/2024
2.1.60 124 2/6/2024
2.1.59 1,417 2/6/2024
2.1.58 125 2/6/2024
2.1.57 903 2/6/2024
2.1.54 117 2/5/2024
2.1.53 117 2/5/2024
2.1.52 2,896 2/4/2024
2.1.51 1,314 2/2/2024
2.1.49 106 2/1/2024
2.1.48 1,710 1/31/2024
2.1.47 1,379 1/29/2024
2.1.46 1,387 1/29/2024
2.1.45 647 1/29/2024
2.1.44 876 1/28/2024
2.1.43 105 1/28/2024
2.1.42 899 1/28/2024
2.1.41 90 1/28/2024
2.1.40 108 1/28/2024
2.1.39 749 1/28/2024
2.1.38 954 1/28/2024
2.1.37 715 1/28/2024
2.1.36 94 1/28/2024
2.1.35 102 1/28/2024
2.1.34 103 1/28/2024
2.1.33 948 1/27/2024
2.1.31 335 1/27/2024
2.1.30 1,069 1/27/2024
2.1.29 989 1/27/2024
2.1.27 541 1/27/2024
2.1.26 1,038 1/27/2024
2.1.25 749 1/26/2024
2.1.24 104 1/26/2024
2.1.23 108 1/26/2024
2.1.22 97 1/26/2024
2.1.21 698 1/26/2024
2.1.20 675 1/26/2024
2.1.19 743 1/26/2024
2.1.18 733 1/26/2024
2.1.17 828 1/26/2024
2.1.16 812 1/26/2024
2.1.15 332 1/25/2024
2.1.14 899 1/25/2024
2.1.13 881 1/25/2024
2.1.12 104 1/25/2024
2.1.11 800 1/25/2024
2.1.10 772 1/25/2024
2.1.9 824 1/25/2024
2.1.7 5,234 1/15/2024
2.1.6 1,197 1/14/2024
2.1.5 1,470 1/14/2024
2.1.4 1,406 1/13/2024
2.1.3 1,404 1/5/2024
2.1.2 145 1/2/2024
2.1.1 196 12/29/2023