Soenneker.Utils.AutoBogus 2.1.270

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

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

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

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

An AutoFakerBinder for interfaces and abstract objects using FakeItEasy

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
2.1.381 2,304 10/17/2024
2.1.380 3,757 10/14/2024
2.1.379 342 10/14/2024
2.1.378 3,728 10/11/2024
2.1.377 603 10/11/2024
2.1.376 5,595 10/8/2024
2.1.375 3,897 10/8/2024
2.1.374 6,487 10/3/2024
2.1.373 57 10/3/2024
2.1.372 57 10/3/2024
2.1.371 1,108 10/3/2024
2.1.370 1,725 10/3/2024
2.1.369 4,848 10/2/2024
2.1.368 67 10/2/2024
2.1.367 5,449 10/1/2024
2.1.366 1,446 10/1/2024
2.1.365 4,684 9/29/2024
2.1.364 1,142 9/29/2024
2.1.363 72 9/29/2024
2.1.362 4,815 9/27/2024
2.1.361 70 9/27/2024
2.1.360 168 9/27/2024
2.1.359 65 9/27/2024
2.1.358 2,581 9/27/2024
2.1.357 70 9/27/2024
2.1.356 65 9/27/2024
2.1.355 3,595 9/27/2024
2.1.354 3,851 9/26/2024
2.1.353 131 9/26/2024
2.1.351 4,857 9/26/2024
2.1.350 2,174 9/25/2024
2.1.349 73 9/25/2024
2.1.348 75 9/25/2024
2.1.347 4,272 9/23/2024
2.1.346 1,965 9/23/2024
2.1.345 1,798 9/23/2024
2.1.344 76 9/23/2024
2.1.343 109 9/23/2024
2.1.342 3,648 9/23/2024
2.1.341 71 9/23/2024
2.1.340 79 9/23/2024
2.1.339 1,340 9/23/2024
2.1.338 70 9/23/2024
2.1.337 1,393 9/22/2024
2.1.336 6,419 9/17/2024
2.1.335 73 9/17/2024
2.1.334 3,209 9/17/2024
2.1.333 2,134 9/17/2024
2.1.332 77 9/17/2024
2.1.331 69 9/17/2024
2.1.330 143 9/17/2024
2.1.328 15,353 9/12/2024
2.1.327 2,605 9/11/2024
2.1.326 890 9/11/2024
2.1.325 2,648 9/11/2024
2.1.324 90 9/11/2024
2.1.323 6,890 9/10/2024
2.1.322 1,209 9/10/2024
2.1.320 2,102 9/9/2024
2.1.319 1,318 9/9/2024
2.1.318 1,798 9/9/2024
2.1.317 4,983 9/9/2024
2.1.316 85 9/9/2024
2.1.315 2,782 9/9/2024
2.1.314 3,769 9/6/2024
2.1.313 2,928 9/6/2024
2.1.312 2,025 9/5/2024
2.1.311 93 9/5/2024
2.1.310 389 9/5/2024
2.1.309 81 9/5/2024
2.1.308 1,636 9/5/2024
2.1.307 85 9/5/2024
2.1.306 95 9/5/2024
2.1.305 86 9/5/2024
2.1.304 97 9/5/2024
2.1.303 95 9/5/2024
2.1.302 6,126 9/4/2024
2.1.301 1,033 9/4/2024
2.1.300 4,292 9/3/2024
2.1.299 2,615 9/3/2024
2.1.298 3,011 9/3/2024
2.1.297 435 9/2/2024
2.1.296 4,419 8/29/2024
2.1.295 3,319 8/25/2024
2.1.294 4,301 8/21/2024
2.1.293 96 8/21/2024
2.1.292 97 8/21/2024
2.1.291 941 8/20/2024
2.1.290 111 8/20/2024
2.1.289 866 8/20/2024
2.1.288 111 8/20/2024
2.1.287 1,911 8/20/2024
2.1.286 98 8/20/2024
2.1.285 97 8/20/2024
2.1.284 6,149 8/19/2024
2.1.283 6,098 8/13/2024
2.1.282 8,001 8/6/2024
2.1.281 994 8/6/2024
2.1.280 4,259 8/1/2024
2.1.279 2,923 7/31/2024
2.1.278 5,040 7/25/2024
2.1.277 67 7/25/2024
2.1.276 1,881 7/24/2024
2.1.275 648 7/24/2024
2.1.274 9,315 7/19/2024
2.1.273 3,555 7/14/2024
2.1.272 1,859 7/14/2024
2.1.271 4,836 7/10/2024
2.1.270 2,558 7/10/2024
2.1.269 893 7/10/2024
2.1.268 85 7/10/2024
2.1.267 404 7/10/2024
2.1.266 644 7/10/2024
2.1.265 91 7/10/2024
2.1.264 1,630 7/9/2024
2.1.261 169 7/9/2024
2.1.260 4,649 7/9/2024
2.1.259 3,236 7/9/2024
2.1.258 89 7/9/2024
2.1.257 693 7/9/2024
2.1.256 97 7/9/2024
2.1.255 1,715 7/9/2024
2.1.254 87 7/9/2024
2.1.253 2,416 7/9/2024
2.1.252 94 7/9/2024
2.1.251 561 7/9/2024
2.1.249 98 7/8/2024
2.1.248 106 7/8/2024
2.1.247 92 7/8/2024
2.1.246 623 7/8/2024
2.1.245 106 7/8/2024
2.1.244 96 7/8/2024
2.1.243 6,103 7/7/2024
2.1.242 1,076 7/7/2024
2.1.241 1,029 7/7/2024
2.1.240 604 7/7/2024
2.1.239 8,590 7/3/2024
2.1.238 842 7/3/2024
2.1.237 7,833 6/21/2024
2.1.236 3,669 6/15/2024
2.1.235 1,618 6/15/2024
2.1.234 7,994 6/1/2024
2.1.233 332 6/1/2024
2.1.232 95 6/1/2024
2.1.231 2,581 6/1/2024
2.1.230 2,977 5/31/2024
2.1.229 2,728 5/29/2024
2.1.228 95 5/29/2024
2.1.227 2,928 5/28/2024
2.1.226 81 5/28/2024
2.1.225 2,013 5/27/2024
2.1.224 91 5/27/2024
2.1.223 3,897 5/26/2024
2.1.221 2,578 5/26/2024
2.1.220 94 5/26/2024
2.1.219 1,807 5/25/2024
2.1.218 86 5/25/2024
2.1.215 882 5/25/2024
2.1.214 93 5/25/2024
2.1.213 2,715 5/25/2024
2.1.212 91 5/25/2024
2.1.211 90 5/25/2024
2.1.210 122 5/25/2024
2.1.208 13,619 5/23/2024
2.1.207 155 5/23/2024
2.1.206 93 5/23/2024
2.1.205 1,286 5/23/2024
2.1.204 96 5/23/2024
2.1.203 1,337 5/22/2024
2.1.202 106 5/22/2024
2.1.201 95 5/22/2024
2.1.200 95 5/22/2024
2.1.199 2,414 5/22/2024
2.1.197 605 5/22/2024
2.1.196 4,694 5/17/2024
2.1.195 1,795 5/17/2024
2.1.194 5,539 5/14/2024
2.1.193 111 5/14/2024
2.1.192 3,247 5/12/2024
2.1.191 7,754 4/29/2024
2.1.190 129 4/29/2024
2.1.189 119 4/29/2024
2.1.188 488 4/29/2024
2.1.187 97 4/29/2024
2.1.186 3,126 4/28/2024
2.1.185 113 4/28/2024
2.1.184 2,134 4/28/2024
2.1.183 844 4/28/2024
2.1.182 2,331 4/28/2024
2.1.181 91 4/28/2024
2.1.180 94 4/28/2024
2.1.179 1,584 4/28/2024
2.1.178 125 4/27/2024
2.1.177 83 4/27/2024
2.1.176 5,935 4/19/2024
2.1.175 2,147 4/18/2024
2.1.174 4,218 4/12/2024
2.1.173 1,709 4/12/2024
2.1.172 566 4/12/2024
2.1.171 427 4/12/2024
2.1.170 95 4/12/2024
2.1.169 112 4/12/2024
2.1.168 2,065 4/12/2024
2.1.167 107 4/12/2024
2.1.166 120 4/12/2024
2.1.165 94 4/12/2024
2.1.164 87 4/12/2024
2.1.163 6,035 4/9/2024
2.1.162 3,282 4/1/2024
2.1.161 108 4/1/2024
2.1.160 6,959 3/25/2024
2.1.159 96 3/25/2024
2.1.158 2,327 3/20/2024
2.1.157 2,133 3/19/2024
2.1.156 1,224 3/19/2024
2.1.155 3,341 3/15/2024
2.1.154 2,107 3/13/2024
2.1.153 880 3/13/2024
2.1.152 392 3/13/2024
2.1.151 115 3/13/2024
2.1.150 106 3/13/2024
2.1.149 113 3/13/2024
2.1.148 130 3/13/2024
2.1.147 2,769 3/12/2024
2.1.146 3,469 3/11/2024
2.1.145 111 3/11/2024
2.1.144 1,270 3/11/2024
2.1.143 1,752 3/9/2024
2.1.142 1,968 3/8/2024
2.1.141 1,292 3/8/2024
2.1.140 2,855 3/6/2024
2.1.139 121 3/6/2024
2.1.138 1,983 3/4/2024
2.1.137 102 3/4/2024
2.1.136 2,710 3/2/2024
2.1.135 1,222 3/2/2024
2.1.134 109 3/2/2024
2.1.133 1,557 3/2/2024
2.1.132 831 3/2/2024
2.1.131 1,802 2/29/2024
2.1.130 1,537 2/29/2024
2.1.129 1,801 2/26/2024
2.1.128 1,609 2/25/2024
2.1.127 104 2/25/2024
2.1.126 2,217 2/23/2024
2.1.125 1,879 2/22/2024
2.1.124 1,112 2/21/2024
2.1.123 1,435 2/21/2024
2.1.122 342 2/21/2024
2.1.121 353 2/21/2024
2.1.120 111 2/21/2024
2.1.119 1,360 2/21/2024
2.1.118 111 2/21/2024
2.1.117 110 2/21/2024
2.1.116 661 2/21/2024
2.1.115 1,021 2/21/2024
2.1.114 116 2/21/2024
2.1.113 111 2/21/2024
2.1.112 111 2/21/2024
2.1.111 818 2/21/2024
2.1.110 111 2/21/2024
2.1.109 2,670 2/20/2024
2.1.108 104 2/20/2024
2.1.107 2,650 2/19/2024
2.1.106 301 2/19/2024
2.1.104 2,890 2/17/2024
2.1.103 1,444 2/16/2024
2.1.102 96 2/16/2024
2.1.101 744 2/16/2024
2.1.100 1,204 2/16/2024
2.1.99 104 2/16/2024
2.1.98 100 2/16/2024
2.1.97 729 2/16/2024
2.1.96 103 2/16/2024
2.1.95 97 2/16/2024
2.1.94 1,457 2/16/2024
2.1.93 103 2/16/2024
2.1.92 2,132 2/13/2024
2.1.91 2,137 2/13/2024
2.1.90 821 2/13/2024
2.1.89 102 2/13/2024
2.1.88 689 2/13/2024
2.1.87 2,112 2/11/2024
2.1.86 814 2/11/2024
2.1.85 119 2/11/2024
2.1.84 1,535 2/11/2024
2.1.83 111 2/11/2024
2.1.82 1,131 2/11/2024
2.1.81 111 2/11/2024
2.1.80 100 2/11/2024
2.1.79 113 2/11/2024
2.1.78 110 2/11/2024
2.1.76 2,454 2/9/2024
2.1.75 110 2/9/2024
2.1.74 1,502 2/9/2024
2.1.73 120 2/9/2024
2.1.72 983 2/8/2024
2.1.71 114 2/8/2024
2.1.70 111 2/8/2024
2.1.69 482 2/8/2024
2.1.68 1,142 2/8/2024
2.1.67 114 2/8/2024
2.1.66 108 2/8/2024
2.1.65 1,141 2/8/2024
2.1.64 103 2/8/2024
2.1.63 808 2/8/2024
2.1.62 2,131 2/7/2024
2.1.61 1,097 2/6/2024
2.1.60 117 2/6/2024
2.1.59 1,408 2/6/2024
2.1.58 118 2/6/2024
2.1.57 895 2/6/2024
2.1.54 113 2/5/2024
2.1.53 112 2/5/2024
2.1.52 2,893 2/4/2024
2.1.51 1,311 2/2/2024
2.1.49 103 2/1/2024
2.1.48 1,707 1/31/2024
2.1.47 1,376 1/29/2024
2.1.46 1,384 1/29/2024
2.1.45 644 1/29/2024
2.1.44 871 1/28/2024
2.1.43 102 1/28/2024
2.1.42 894 1/28/2024
2.1.41 87 1/28/2024
2.1.40 105 1/28/2024
2.1.39 746 1/28/2024
2.1.38 951 1/28/2024
2.1.37 712 1/28/2024
2.1.36 89 1/28/2024
2.1.35 99 1/28/2024
2.1.34 100 1/28/2024
2.1.33 940 1/27/2024
2.1.31 329 1/27/2024
2.1.30 1,066 1/27/2024
2.1.29 986 1/27/2024
2.1.27 538 1/27/2024
2.1.26 1,033 1/27/2024
2.1.25 744 1/26/2024
2.1.24 101 1/26/2024
2.1.23 103 1/26/2024
2.1.22 90 1/26/2024
2.1.21 691 1/26/2024
2.1.20 672 1/26/2024
2.1.19 740 1/26/2024
2.1.18 730 1/26/2024
2.1.17 825 1/26/2024
2.1.16 807 1/26/2024
2.1.15 327 1/25/2024
2.1.14 896 1/25/2024
2.1.13 878 1/25/2024
2.1.12 101 1/25/2024
2.1.11 795 1/25/2024
2.1.10 769 1/25/2024
2.1.9 821 1/25/2024
2.1.7 5,229 1/15/2024
2.1.6 1,194 1/14/2024
2.1.5 1,467 1/14/2024
2.1.4 1,403 1/13/2024
2.1.3 1,399 1/5/2024
2.1.2 142 1/2/2024
2.1.1 163 12/29/2023