Repository: bchavez/Bogus
Branch: master
Commit: 6ece18c5c226
Files: 415
Total size: 3.3 MB
Directory structure:
gitextract_1wf4tuk4/
├── .config/
│ └── dotnet-tools.json
├── .editorconfig
├── .gitattributes
├── .github/
│ ├── FUNDING.yml
│ └── ISSUE_TEMPLATE/
│ ├── bug_report.yml
│ ├── config.yml
│ ├── feature_request.yml
│ └── support.yml
├── .gitignore
├── .gitmodules
├── .nuke/
│ ├── build.schema.json
│ └── parameters.json
├── CONTRIBUTING.md
├── Examples/
│ ├── EFCoreSeedDb/
│ │ ├── .config/
│ │ │ └── dotnet-tools.json
│ │ ├── EFCoreSeedDb.csproj
│ │ ├── Program.cs
│ │ └── README.md
│ ├── Examples.sln
│ ├── ExtendingBogus/
│ │ ├── ExtendingBogus.csproj
│ │ ├── ExtensionsForAddress.cs
│ │ ├── ExtensionsForTesting.cs
│ │ ├── FoodDataSet.cs
│ │ ├── Program.cs
│ │ └── README.md
│ └── GettingStarted/
│ ├── GettingStarted.csproj
│ ├── Program.cs
│ └── README.md
├── HISTORY.md
├── LICENSE
├── README.md
├── Source/
│ ├── .editorconfig
│ ├── Benchmark/
│ │ ├── BenchGenerate.cs
│ │ ├── BenchRandomSubset.cs
│ │ ├── BenchSsn.cs
│ │ ├── BenchStringFill.cs
│ │ ├── Benchmark.csproj
│ │ ├── PR300_BenchDecimal.cs
│ │ ├── PR300_BenchRandomNumber.cs
│ │ └── README.md
│ ├── Bogus/
│ │ ├── Binder.cs
│ │ ├── Bogus.csproj
│ │ ├── Bogus.ruleset
│ │ ├── BogusException.cs
│ │ ├── Bson/
│ │ │ ├── BArray.cs
│ │ │ ├── BObject.cs
│ │ │ ├── BValue.cs
│ │ │ ├── BValueType.cs
│ │ │ └── Bson.cs
│ │ ├── Chars.cs
│ │ ├── DataCategoryAttribute.cs
│ │ ├── DataSet.cs
│ │ ├── DataSets/
│ │ │ ├── Address.cs
│ │ │ ├── ColorFormat.cs
│ │ │ ├── Commerce.cs
│ │ │ ├── Company.cs
│ │ │ ├── Database.cs
│ │ │ ├── Date.cs
│ │ │ ├── Date.net60.cs
│ │ │ ├── Finance.cs
│ │ │ ├── Hacker.cs
│ │ │ ├── Images.PlaceImg.cs
│ │ │ ├── Images.cs
│ │ │ ├── Internet.cs
│ │ │ ├── Lorem.cs
│ │ │ ├── Music.cs
│ │ │ ├── Name.cs
│ │ │ ├── PhoneNumbers.cs
│ │ │ ├── Rant.cs
│ │ │ ├── System.cs
│ │ │ └── Vehicle.cs
│ │ ├── Database.cs
│ │ ├── Distributions/
│ │ │ └── Gaussian/
│ │ │ └── ExtensionsForRandomizer.cs
│ │ ├── Extensions/
│ │ │ ├── Belgium/
│ │ │ │ └── ExtensionsForBelgium.cs
│ │ │ ├── Brazil/
│ │ │ │ └── ExtensionsForBrazil.cs
│ │ │ ├── Canada/
│ │ │ │ └── ExtensionsForCanada.cs
│ │ │ ├── Denmark/
│ │ │ │ └── ExtensionsForDenmark.cs
│ │ │ ├── ExtensionsForCultureInfo.cs
│ │ │ ├── ExtensionsForPropertyInfo.cs
│ │ │ ├── ExtensionsForRandomizer.cs
│ │ │ ├── ExtensionsForString.cs
│ │ │ ├── Extras/
│ │ │ │ ├── CheckDigitExtension.cs
│ │ │ │ └── FinanceExtensions.cs
│ │ │ ├── Finland/
│ │ │ │ └── ExtensionsForFinland.cs
│ │ │ ├── Iran/
│ │ │ │ └── ExtensionsForIran.cs
│ │ │ ├── Italy/
│ │ │ │ ├── ExtensionsForItaly.CodiceFiscale.cs
│ │ │ │ └── ExtensionsForItaly.cs
│ │ │ ├── Norway/
│ │ │ │ └── ExtensionsForNorway.cs
│ │ │ ├── Poland/
│ │ │ │ └── ExtensionsForPoland.cs
│ │ │ ├── Portugal/
│ │ │ │ ├── ExtensionsForPortugal.cs
│ │ │ │ └── TaxNumberGenerator.cs
│ │ │ ├── Romania/
│ │ │ │ ├── ExtensionsForRomania.cs
│ │ │ │ └── RomanianBirthCounty.cs
│ │ │ ├── Sweden/
│ │ │ │ └── ExtensionsForSweden.cs
│ │ │ ├── UnitedKingdom/
│ │ │ │ ├── ExtensionsForGreatBritainRegistrationPlate.cs
│ │ │ │ ├── ExtensionsForUnitedKingdom.cs
│ │ │ │ └── VatRegistrationNumberType.cs
│ │ │ └── UnitedStates/
│ │ │ └── ExtensionsForUnitedStates.cs
│ │ ├── Faker.cs
│ │ ├── Faker[T].Extensions.cs
│ │ ├── Faker[T].cs
│ │ ├── Hashids.cs
│ │ ├── IHashids.cs
│ │ ├── ILocaleAware.cs
│ │ ├── IRuleSet.cs
│ │ ├── Person.cs
│ │ ├── Platform/
│ │ │ └── ExtensionsForType.cs
│ │ ├── Premium/
│ │ │ ├── ContextHelper.cs
│ │ │ ├── License.cs
│ │ │ ├── LicenseVerifier.cs
│ │ │ └── PremiumDataSet.cs
│ │ ├── Properties/
│ │ │ └── AssemblyInfo.cs
│ │ ├── PropertyName.cs
│ │ ├── Randomizer.cs
│ │ ├── ResourceHelper.cs
│ │ ├── Rule.cs
│ │ ├── SeedNotifier[T].cs
│ │ ├── Tokenizer.cs
│ │ ├── Transliterater.Generated.cs
│ │ ├── Transliterater.cs
│ │ ├── Utils.cs
│ │ ├── ValidationException.cs
│ │ ├── ValidationResult.cs
│ │ ├── Vendor/
│ │ │ └── UserAgentGenerator.cs
│ │ ├── data/
│ │ │ ├── README.md
│ │ │ ├── _DO_NOT_MODIFY_FILES_IN_THIS_FOLDER
│ │ │ ├── af_ZA.locale.bson
│ │ │ ├── af_ZA.locale.json
│ │ │ ├── af_ZA.locale.schema.verified.txt
│ │ │ ├── ar.locale.bson
│ │ │ ├── ar.locale.json
│ │ │ ├── ar.locale.schema.verified.txt
│ │ │ ├── az.locale.bson
│ │ │ ├── az.locale.json
│ │ │ ├── az.locale.schema.verified.txt
│ │ │ ├── cz.locale.bson
│ │ │ ├── cz.locale.json
│ │ │ ├── cz.locale.schema.verified.txt
│ │ │ ├── de.locale.bson
│ │ │ ├── de.locale.json
│ │ │ ├── de.locale.schema.verified.txt
│ │ │ ├── de_AT.locale.bson
│ │ │ ├── de_AT.locale.json
│ │ │ ├── de_AT.locale.schema.verified.txt
│ │ │ ├── de_CH.locale.bson
│ │ │ ├── de_CH.locale.json
│ │ │ ├── de_CH.locale.schema.verified.txt
│ │ │ ├── el.locale.bson
│ │ │ ├── el.locale.json
│ │ │ ├── el.locale.schema.verified.txt
│ │ │ ├── en.locale.bson
│ │ │ ├── en.locale.json
│ │ │ ├── en.locale.schema.verified.txt
│ │ │ ├── en_AU.locale.bson
│ │ │ ├── en_AU.locale.json
│ │ │ ├── en_AU.locale.schema.verified.txt
│ │ │ ├── en_AU_ocker.locale.bson
│ │ │ ├── en_AU_ocker.locale.json
│ │ │ ├── en_AU_ocker.locale.schema.verified.txt
│ │ │ ├── en_BORK.locale.bson
│ │ │ ├── en_BORK.locale.json
│ │ │ ├── en_BORK.locale.schema.verified.txt
│ │ │ ├── en_CA.locale.bson
│ │ │ ├── en_CA.locale.json
│ │ │ ├── en_CA.locale.schema.verified.txt
│ │ │ ├── en_GB.locale.bson
│ │ │ ├── en_GB.locale.json
│ │ │ ├── en_GB.locale.schema.verified.txt
│ │ │ ├── en_IE.locale.bson
│ │ │ ├── en_IE.locale.json
│ │ │ ├── en_IE.locale.schema.verified.txt
│ │ │ ├── en_IND.locale.bson
│ │ │ ├── en_IND.locale.json
│ │ │ ├── en_IND.locale.schema.verified.txt
│ │ │ ├── en_NG.locale.bson
│ │ │ ├── en_NG.locale.json
│ │ │ ├── en_NG.locale.schema.verified.txt
│ │ │ ├── en_US.locale.bson
│ │ │ ├── en_US.locale.json
│ │ │ ├── en_US.locale.schema.verified.txt
│ │ │ ├── en_ZA.locale.bson
│ │ │ ├── en_ZA.locale.json
│ │ │ ├── en_ZA.locale.schema.verified.txt
│ │ │ ├── es.locale.bson
│ │ │ ├── es.locale.json
│ │ │ ├── es.locale.schema.verified.txt
│ │ │ ├── es_MX.locale.bson
│ │ │ ├── es_MX.locale.json
│ │ │ ├── es_MX.locale.schema.verified.txt
│ │ │ ├── fa.locale.bson
│ │ │ ├── fa.locale.json
│ │ │ ├── fa.locale.schema.verified.txt
│ │ │ ├── fi.locale.bson
│ │ │ ├── fi.locale.json
│ │ │ ├── fi.locale.schema.verified.txt
│ │ │ ├── fr.locale.bson
│ │ │ ├── fr.locale.json
│ │ │ ├── fr.locale.schema.verified.txt
│ │ │ ├── fr_CA.locale.bson
│ │ │ ├── fr_CA.locale.json
│ │ │ ├── fr_CA.locale.schema.verified.txt
│ │ │ ├── fr_CH.locale.bson
│ │ │ ├── fr_CH.locale.json
│ │ │ ├── fr_CH.locale.schema.verified.txt
│ │ │ ├── ge.locale.bson
│ │ │ ├── ge.locale.json
│ │ │ ├── ge.locale.schema.verified.txt
│ │ │ ├── hr.locale.bson
│ │ │ ├── hr.locale.json
│ │ │ ├── hr.locale.schema.verified.txt
│ │ │ ├── id_ID.locale.bson
│ │ │ ├── id_ID.locale.json
│ │ │ ├── id_ID.locale.schema.verified.txt
│ │ │ ├── it.locale.bson
│ │ │ ├── it.locale.json
│ │ │ ├── it.locale.schema.verified.txt
│ │ │ ├── ja.locale.bson
│ │ │ ├── ja.locale.json
│ │ │ ├── ja.locale.schema.verified.txt
│ │ │ ├── ko.locale.bson
│ │ │ ├── ko.locale.json
│ │ │ ├── ko.locale.schema.verified.txt
│ │ │ ├── lv.locale.bson
│ │ │ ├── lv.locale.json
│ │ │ ├── lv.locale.schema.verified.txt
│ │ │ ├── nb_NO.locale.bson
│ │ │ ├── nb_NO.locale.json
│ │ │ ├── nb_NO.locale.schema.verified.txt
│ │ │ ├── ne.locale.bson
│ │ │ ├── ne.locale.json
│ │ │ ├── ne.locale.schema.verified.txt
│ │ │ ├── nl.locale.bson
│ │ │ ├── nl.locale.json
│ │ │ ├── nl.locale.schema.verified.txt
│ │ │ ├── nl_BE.locale.bson
│ │ │ ├── nl_BE.locale.json
│ │ │ ├── nl_BE.locale.schema.verified.txt
│ │ │ ├── pl.locale.bson
│ │ │ ├── pl.locale.json
│ │ │ ├── pl.locale.schema.verified.txt
│ │ │ ├── pt_BR.locale.bson
│ │ │ ├── pt_BR.locale.json
│ │ │ ├── pt_BR.locale.schema.verified.txt
│ │ │ ├── pt_PT.locale.bson
│ │ │ ├── pt_PT.locale.json
│ │ │ ├── pt_PT.locale.schema.verified.txt
│ │ │ ├── ro.locale.bson
│ │ │ ├── ro.locale.json
│ │ │ ├── ro.locale.schema.verified.txt
│ │ │ ├── ru.locale.bson
│ │ │ ├── ru.locale.json
│ │ │ ├── ru.locale.schema.verified.txt
│ │ │ ├── sk.locale.bson
│ │ │ ├── sk.locale.json
│ │ │ ├── sk.locale.schema.verified.txt
│ │ │ ├── sv.locale.bson
│ │ │ ├── sv.locale.json
│ │ │ ├── sv.locale.schema.verified.txt
│ │ │ ├── tr.locale.bson
│ │ │ ├── tr.locale.json
│ │ │ ├── tr.locale.schema.verified.txt
│ │ │ ├── uk.locale.bson
│ │ │ ├── uk.locale.json
│ │ │ ├── uk.locale.schema.verified.txt
│ │ │ ├── vi.locale.bson
│ │ │ ├── vi.locale.json
│ │ │ ├── vi.locale.schema.verified.txt
│ │ │ ├── zh_CN.locale.bson
│ │ │ ├── zh_CN.locale.json
│ │ │ ├── zh_CN.locale.schema.verified.txt
│ │ │ ├── zh_TW.locale.bson
│ │ │ ├── zh_TW.locale.json
│ │ │ ├── zh_TW.locale.schema.verified.txt
│ │ │ ├── zu_ZA.locale.bson
│ │ │ ├── zu_ZA.locale.json
│ │ │ └── zu_ZA.locale.schema.verified.txt
│ │ └── data_extend/
│ │ ├── az.locale.json
│ │ ├── en.locale.json
│ │ ├── nl.locale.json
│ │ ├── pt_BR.locale.json
│ │ ├── pt_PT.locale.json
│ │ ├── sv.locale.json
│ │ └── tr.locale.json
│ ├── Bogus.Tests/
│ │ ├── Bogus.Tests.csproj
│ │ ├── BsonTests.cs
│ │ ├── CloneTests.cs
│ │ ├── DataSetTests/
│ │ │ ├── AddressTest.cs
│ │ │ ├── CardTests.cs
│ │ │ ├── CommerceTest.cs
│ │ │ ├── CompanyTest.cs
│ │ │ ├── DatabaseTests.cs
│ │ │ ├── DateTest.cs
│ │ │ ├── DateTest.net60.cs
│ │ │ ├── FinanceTest.cs
│ │ │ ├── HackerTests.cs
│ │ │ ├── ImageTest.cs
│ │ │ ├── InternetTests.cs
│ │ │ ├── LoremTests.cs
│ │ │ ├── MusicTests.cs
│ │ │ ├── NameTests.cs
│ │ │ ├── PhoneNumbersTest.cs
│ │ │ ├── RantTests.cs
│ │ │ ├── SystemTest.cs
│ │ │ └── VehicleTest.cs
│ │ ├── DistributionTests/
│ │ │ └── GaussianTests.cs
│ │ ├── ExtensionTests/
│ │ │ ├── BelgianExtensionTests.cs
│ │ │ ├── DanishExtentionTest.cs
│ │ │ ├── ExtensionTest.cs
│ │ │ ├── IranianExtensionTests.cs
│ │ │ ├── NorwegianExtensionTest.cs
│ │ │ ├── PolishExtensionTest.cs
│ │ │ ├── RegistrationPlateExtensionsForGreatBritainTests.cs
│ │ │ └── SwedishExtensionTest.cs
│ │ ├── ExtensionsForTesting.cs
│ │ ├── FluentTests.cs
│ │ ├── GitHubIssues/
│ │ │ ├── Issue10.cs
│ │ │ ├── Issue100.cs
│ │ │ ├── Issue102.cs
│ │ │ ├── Issue104.cs
│ │ │ ├── Issue114.cs
│ │ │ ├── Issue115.cs
│ │ │ ├── Issue121.cs
│ │ │ ├── Issue124.cs
│ │ │ ├── Issue126.cs
│ │ │ ├── Issue13.cs
│ │ │ ├── Issue132.cs
│ │ │ ├── Issue134.cs
│ │ │ ├── Issue143.cs
│ │ │ ├── Issue152.cs
│ │ │ ├── Issue168.cs
│ │ │ ├── Issue169.cs
│ │ │ ├── Issue178.cs
│ │ │ ├── Issue179.cs
│ │ │ ├── Issue192.cs
│ │ │ ├── Issue193.cs
│ │ │ ├── Issue218.cs
│ │ │ ├── Issue225.cs
│ │ │ ├── Issue23.cs
│ │ │ ├── Issue232.cs
│ │ │ ├── Issue249.cs
│ │ │ ├── Issue253.cs
│ │ │ ├── Issue255.cs
│ │ │ ├── Issue260.cs
│ │ │ ├── Issue271.cs
│ │ │ ├── Issue279.cs
│ │ │ ├── Issue280.cs
│ │ │ ├── Issue309.cs
│ │ │ ├── Issue313.cs
│ │ │ ├── Issue318.cs
│ │ │ ├── Issue319.cs
│ │ │ ├── Issue321.cs
│ │ │ ├── Issue328.cs
│ │ │ ├── Issue342.cs
│ │ │ ├── Issue355.cs
│ │ │ ├── Issue389.cs
│ │ │ ├── Issue411.cs
│ │ │ ├── Issue45.cs
│ │ │ ├── Issue48.cs
│ │ │ ├── Issue49.cs
│ │ │ ├── Issue538.cs
│ │ │ ├── Issue55.cs
│ │ │ ├── Issue581.cs
│ │ │ ├── Issue601.cs
│ │ │ ├── Issue61.cs
│ │ │ ├── Issue70.cs
│ │ │ ├── Issue86.cs
│ │ │ ├── Issue93.cs
│ │ │ ├── Issue99.cs
│ │ │ ├── PullRequest149.cs
│ │ │ ├── PullRequest180.cs
│ │ │ ├── PullRequest194.cs
│ │ │ ├── PullRequest197.cs
│ │ │ ├── PullRequest258.cs
│ │ │ ├── PullRequest259.cs
│ │ │ ├── PullRequest261.cs
│ │ │ ├── PullRequest500.cs
│ │ │ ├── PullRequest510.cs
│ │ │ └── PullRequest513.cs
│ │ ├── HandleBarTests.cs
│ │ ├── HandlebarsTests/
│ │ │ └── ArgumentsTest.cs
│ │ ├── LocaleTests/
│ │ │ ├── PtLocale.cs
│ │ │ └── TrLocale.cs
│ │ ├── Models/
│ │ │ └── Order.cs
│ │ ├── PersonTest.cs
│ │ ├── README_Generator.cs
│ │ ├── RandomizerTest.cs
│ │ ├── Rant_Generator.cs
│ │ ├── Rantionary-3.0.17.rantpkg
│ │ ├── RuleSetTests.cs
│ │ ├── SchemaTests/
│ │ │ └── LocaleSchemaTests.cs
│ │ ├── SeededTest.cs
│ │ ├── StackOverflowQuestions/
│ │ │ ├── Question60136934.cs
│ │ │ └── Question66444118.cs
│ │ ├── StrictModeTests.cs
│ │ ├── TransliterateTests.cs
│ │ ├── UniquenessTests.cs
│ │ └── ValidationDeltaTests.cs
│ ├── Bogus.sln
│ ├── Bogus.snk.pub
│ ├── Builder/
│ │ ├── .editorconfig
│ │ ├── .vscode/
│ │ │ └── launch.json
│ │ ├── Build.cs
│ │ ├── Builder.csproj
│ │ ├── Configuration.cs
│ │ ├── Directory.Build.props
│ │ ├── Directory.Build.targets
│ │ ├── Utils.cs
│ │ ├── gulpfile.js
│ │ ├── package.json
│ │ └── test.js
│ └── Directory.Build.props
├── appveyor.yml
├── build.cmd
├── build.ps1
├── build.sh
└── global.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .config/dotnet-tools.json
================================================
{
"version": 1,
"isRoot": true,
"tools": {
"benchmarkdotnet.tool": {
"version": "0.12.1",
"commands": [
"dotnet-benchmark"
]
},
"nuke.globaltool": {
"version": "9.0.3",
"commands": [
"nuke"
]
}
}
}
================================================
FILE: .editorconfig
================================================
root=true
[*.cs]
trim_trailing_whitespace=true
insert_final_newline=true
[*]
indent_style = space
indent_size = 3
[*.{fs,fsx}]
indent_style = space
indent_size = 4
[*.{md,markdown,json,js,csproj,fsproj,targets}]
indent_style = space
indent_size = 2
# Verify settings
[*.{received,verified}.{txt,xml,json}]
charset = "utf-8-bom"
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
* text=auto
*.cs diff=csharp
# Custom for Visual Studio
*.sln text eol=crlf merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: bchavez
custom: https://github.com/bchavez/Bogus/wiki/Bogus-Premium
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.yml
================================================
name: 🐞 Bug Report
description: "Report something that doesn't look right 🔧"
labels: [""]
body:
- type: markdown
attributes:
value: |
## Version Information
- type: input
id: version-bogus
attributes:
label: Bogus NuGet Package
description: What version of Bogus are you using?
placeholder: ex. v35.0.1
validations:
required: true
- type: input
id: version-dotnet
attributes:
label: .NET Version
description: What version of .NET are using?
placeholder: ex. Full Framework 4.7.1 or .NET 8?
validations:
required: true
- type: input
id: version-visualstudio
attributes:
label: Visual Studio Version
description: What version of Visual Studio are using?
placeholder: ex. 17.8?
validations:
required: false
- type: dropdown
id: operating-system
attributes:
label: What operating system are you using?
multiple: false
options:
- Windows
- Linux
- MacOS
- Other
validations:
required: true
- type: markdown
attributes:
value: |
## Bug Report
- type: input
id: bogus-locale
attributes:
label: What locale are you using with Bogus?
description:
placeholder: ex. en_GB
validations:
required: true
- type: textarea
id: problem-description
attributes:
label: Problem Description
description: Please share a clear and concise description of the problem.
placeholder:
validations:
required: true
- type: textarea
id: problem-linqpad-repro-steps
attributes:
label: LINQPad Example or Reproduction Steps
description: |
Please provide a LINQPad example of the problem or provide reproduction steps. LINQPad can be downloaded here: https://www.linqpad.net/.
placeholder: "LINQPad can be downloaded here: https://www.linqpad.net/"
validations:
required: true
- type: textarea
id: bogus-expected-behavior
attributes:
label: Expected Behavior
description: Provide a description of the expected behavior.
placeholder: Expected Behavior
validations:
required: true
- type: textarea
id: bogus-actual-behavior
attributes:
label: Actual Behavior
description: |
Provide a description of the actual behavior observed. Please include any error messages, exception stacktraces, logs, and/or screenshots.
placeholder: Actual Behavior
validations:
required: true
- type: textarea
id: known-workarounds
attributes:
label: Known Workarounds
description: |
Please provide a description of any known workarounds.
placeholder: Known Workarounds
validations:
required: false
- type: dropdown
id: can-send-pr
attributes:
label: Could you help with a pull-request?
description: If the bug is confirmed, would you be willing to submit a pull-request?
options:
- "No"
- "Yes"
validations:
required: true
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: true
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.yml
================================================
name: 🚀 Feature request
description: If you have a feature request 💡
labels: [""]
body:
- type: textarea
id: feature-why
attributes:
label: Description
description: Please describe why you are requesting this feature.
placeholder:
validations:
required: true
- type: textarea
id: feature-code-example
attributes:
label: LINQPad Code Example
description: |
Please provide a LINQPad example of what you are trying to achieve. LINQPad can be downloaded here: https://www.linqpad.net/.
placeholder: "LINQPad can be downloaded here: https://www.linqpad.net/"
validations:
required: true
- type: textarea
id: feature-alternatives
attributes:
label: What alternatives have you considered?
description: Are there any workarounds or alternatives?
placeholder:
validations:
required: true
- type: dropdown
id: feature-can-send-pr
attributes:
label: Could you help with a pull-request?
description: If the bug is confirmed, would you be willing to submit a pull-request?
options:
- "No"
- "Yes"
validations:
required: true
================================================
FILE: .github/ISSUE_TEMPLATE/support.yml
================================================
name: ❓ Support
description: "If you need help using Bogus 🏥"
labels: ["question"]
body:
- type: markdown
attributes:
value: |
## Version Information
- type: input
id: version-bogus
attributes:
label: Bogus NuGet Package
description: What version of Bogus are you using?
placeholder: ex. v35.0.1
validations:
required: true
- type: input
id: version-dotnet
attributes:
label: .NET Version
description: What version of .NET are using?
placeholder: ex. Full Framework 4.7.1 or .NET 8?
validations:
required: true
- type: input
id: version-visualstudio
attributes:
label: Visual Studio Version
description: What version of Visual Studio are using?
placeholder: ex. 17.8?
validations:
required: false
- type: dropdown
id: operating-system
attributes:
label: What operating system are you using?
multiple: false
options:
- Windows
- Linux
- MacOS
- Other
validations:
required: true
- type: markdown
attributes:
value: |
## Support Issue
- type: input
id: bogus-locale
attributes:
label: What locale are you using with Bogus?
description:
placeholder: ex. en_GB
validations:
required: true
- type: textarea
id: support-request
attributes:
label: What's the problem?
description: Please describe the support issue.
placeholder:
validations:
required: true
- type: textarea
id: support-linqpad
attributes:
label: Provide LINQPad Example
description: |
Please provide a LINQPad example of what you are trying to do. LINQPad can be downloaded here: https://www.linqpad.net/.
placeholder: "LINQPad can be downloaded here: https://www.linqpad.net/"
validations:
required: true
- type: textarea
id: support-alternatives
attributes:
label: What other possible solutions or alternatives have you considered?
description: Are there any workarounds or alternatives?
placeholder:
validations:
required: true
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# custom
**.lock.json
*.history.nuspec
**/.vs/**
**/.idea/**
/Source/packages**
paket.lock
.fake
.store
.paket/paket.exe
/Source/.paket/**
__test
/__package
/__compile
/Source/Bogus.snk
Source/Builder/node_modules/**
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
**/packages/**
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
/nuget.push.bat
/Source/Benchmark/BenchmarkDotNet.Artifacts/
================================================
FILE: .gitmodules
================================================
[submodule "Source/fakerjs"]
path = Source/fakerjs
url = https://github.com/faker-js/faker.js.git
[submodule "Source/hashids"]
path = Source/hashids
url = https://github.com/ullmark/hashids.net.git
[submodule "Source/speakingurl"]
path = Source/speakingurl
url = https://github.com/pid/speakingurl.git
================================================
FILE: .nuke/build.schema.json
================================================
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"Host": {
"type": "string",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"ExecutableTarget": {
"type": "string",
"enum": [
"BuildInfo",
"CI",
"Clean",
"Compile",
"Pack",
"Restore",
"SetupSnk",
"Test",
"Zip"
]
},
"Verbosity": {
"type": "string",
"description": "",
"enum": [
"Verbose",
"Normal",
"Minimal",
"Quiet"
]
},
"NukeBuild": {
"properties": {
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"description": "Host for execution. Default is 'automatic'",
"$ref": "#/definitions/Host"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"$ref": "#/definitions/ExecutableTarget"
}
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"$ref": "#/definitions/ExecutableTarget"
}
},
"Verbosity": {
"description": "Logging verbosity during build execution. Default is 'Normal'",
"$ref": "#/definitions/Verbosity"
}
}
}
},
"allOf": [
{
"properties": {
"BogusSnkZipPassword": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
}
}
},
{
"$ref": "#/definitions/NukeBuild"
}
]
}
================================================
FILE: .nuke/parameters.json
================================================
{
"$schema": "./build.schema.json",
"Solution": "Source/Bogus.sln"
}
================================================
FILE: CONTRIBUTING.md
================================================
New Features
------------
Bogus a superset of **faker.js**'s features. Adding additional features are welcome. New features and additional APIs can be added so long as we maintain semantic API compatibility with **faker.js** and maintain compatibility with **faker.js** locale data.
Contributing
------------
Here are some helpful guidelines to keep in mind when contributing. While following them isn't absolutely required, it does help everyone to accept your pull-requests with maximum awesomeness.
* :heavy_check_mark: **CONSIDER** adding a unit test if your PR resolves an issue or adds features.
* :heavy_check_mark: **DO** add XML comment documentation to new API calls along parameter documentation.
* :heavy_check_mark: **DO** reference any GH issues in the PR description.
* :heavy_check_mark: **DO** keep pull requests small so they can be easily reviewed.
* :heavy_check_mark: **DO** keep the PR/change-set strictly focused on a specific change and on topic (ie: don't include code re-formatting). If you'd like to change something else off-topic, feel free to set up a new GH issue or PR for those off-topic changes.
* :heavy_check_mark: **DO** make sure unit tests pass.
* :x: **AVOID** changing existing code formatting (spaces, braces, tabs, new lines).
* :x: **AVOID** breaking the continuous integration build.
* :x: **AVOID** Breaking compatibility with **faker.js** locale data.
* :x: **AVOID** Adding new locales to Bogus. New locales should be added upstream to **faker.js**. [See this wiki page for creating locales](https://github.com/bchavez/Bogus/wiki/Creating-Locales).
================================================
FILE: Examples/EFCoreSeedDb/.config/dotnet-tools.json
================================================
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.7",
"commands": [
"dotnet-ef"
]
}
}
}
================================================
FILE: Examples/EFCoreSeedDb/EFCoreSeedDb.csproj
================================================
Exenet8.0runtime; build; native; contentfiles; analyzers; buildtransitiveall
================================================
FILE: Examples/EFCoreSeedDb/Program.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using Bogus;
using Bogus.Extensions;
using Microsoft.EntityFrameworkCore;
using static System.Console;
namespace EFCoreSeedDb
{
class Program
{
static void Main(string[] args)
{
WriteLine("Bogus Blog Example!");
using var ctx = new BloggingContext();
var blogs = ctx.Blogs
.Include(b => b.Posts)
.ToList();
foreach( var blog in blogs)
{
WriteLine($"Blog Id: {blog.BlogId}");
WriteLine($"Blog Url: {blog.Url}");
foreach( var post in blog.Posts )
{
WriteLine($" Post Id: {post.PostId}");
WriteLine($" Title: {post.Title}");
WriteLine($" Content: {post.Content}");
}
WriteLine();
WriteLine();
}
}
}
public class BloggingContext : DbContext
{
public DbSet Blogs { get; set; }
public DbSet Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseSqlite("Data Source=blogging.db");
options.EnableSensitiveDataLogging();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
FakeData.Init(10);
modelBuilder.Entity().HasData(FakeData.Blogs);
modelBuilder.Entity().HasData(FakeData.Posts);
}
}
///
/// Example uses Faker[T]
///
public static class FakeData
{
public static List Blogs = new List();
public static List Posts = new List();
public static void Init(int count)
{
var postId = 1;
var postFaker = new Faker()
.RuleFor(p => p.PostId, _ => postId++)
.RuleFor(p => p.Title, f => f.Hacker.Phrase())
.RuleFor(p => p.Content, f => f.Lorem.Sentence());
var blogId = 1;
var blogFaker = new Faker()
.RuleFor(b => b.BlogId, _ => blogId++)
.RuleFor(b => b.Url, f => f.Internet.Url())
.RuleFor(b => b.Posts, (f, b) =>
{
postFaker.RuleFor(p => p.BlogId, _ => b.BlogId);
var posts = postFaker.GenerateBetween(3, 5);
FakeData.Posts.AddRange(posts);
return null; // Blog.Posts is a getter only. The return value has no impact.
});
var blogs = blogFaker.Generate(count);
FakeData.Blogs.AddRange(blogs);
}
}
///
/// Example uses Faker facade
///
public static class FakeData2
{
public static int BlogId = 1;
public static List Blogs = new List();
public static int PostId = 1;
public static List Posts = new List();
private static Faker f;
public static void Init(int count)
{
f = new Faker();
GenerateBlogs(count);
}
private static void GenerateBlogs(int blogCount)
{
for( var i = 0; i < blogCount; i++, BlogId++ )
{
var blog = new Blog
{
BlogId = BlogId,
Url = f.Internet.Url()
};
Blogs.Add(blog);
var postCount = f.Random.Number(3, 5);
GeneratePost(blog, postCount);
};
}
private static void GeneratePost(Blog b, int postCount)
{
for( var i = 0; i < postCount; i++, PostId++ )
{
var post = new Post
{
PostId = PostId,
BlogId = b.BlogId,
Title = f.Hacker.Phrase(),
Content = f.Lorem.Sentence()
};
Posts.Add(post);
}
}
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List Posts { get; } = new List();
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
}
}
================================================
FILE: Examples/EFCoreSeedDb/README.md
================================================
[1]:https://docs.microsoft.com/en-us/ef/core/get-started/
[2]:https://docs.microsoft.com/en-us/ef/core/modeling/data-seeding
## EF Core Seed Database Example with Bogus
#### Requirements
* **.NET 8.0*** or later
* **EF Core 8** or later
#### Description
The `EFCoreSeedDb` example is based on the [**EF Core Tutorial**][1] with the [**HasData**][2] method using **Bogus**.
To run the example, perform the following commands *inside* this `EfCoreSeedDb` folder:
* `dotnet restore`
* `dotnet build`
* `dotnet ef migrations add InitialCreate`
* `dotnet ef database update`
* `dotnet run`
After the `dotnet` commands are executed above, you should have a `blogging.db` SQLite DB file that you can open and inspect the sample data generated from Bogus. Additionally, the `dotnet run` command will print out the data generated by Bogus to the console read from the `blogging.db` SQLite DB file.
The basic approach is to pre-generate your Bogus data in-memory, in static properties, before sending sample data to EF Core.
* `FakeData` - Uses the `Faker` approach.
* `FakeData2` - Uses the `Faker` facade approach.
Either approach above can be used; pick whichever fits your preference and coding style.
================================================
FILE: Examples/Examples.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 16.0.29613.14
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCoreSeedDb", "EFCoreSeedDb\EFCoreSeedDb.csproj", "{7B012C90-4B93-4DB8-A0BA-AA91460DE392}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStarted", "GettingStarted\GettingStarted.csproj", "{4B10A48D-F572-4984-8C61-8598E792436A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtendingBogus", "ExtendingBogus\ExtendingBogus.csproj", "{44E22B4C-4280-4329-9A7E-3DEC7D487595}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|x64.ActiveCfg = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|x64.Build.0 = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|x86.ActiveCfg = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Debug|x86.Build.0 = Debug|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|Any CPU.Build.0 = Release|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|x64.ActiveCfg = Release|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|x64.Build.0 = Release|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|x86.ActiveCfg = Release|Any CPU
{7B012C90-4B93-4DB8-A0BA-AA91460DE392}.Release|x86.Build.0 = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|x64.ActiveCfg = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|x64.Build.0 = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|x86.ActiveCfg = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Debug|x86.Build.0 = Debug|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|Any CPU.Build.0 = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|x64.ActiveCfg = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|x64.Build.0 = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|x86.ActiveCfg = Release|Any CPU
{4B10A48D-F572-4984-8C61-8598E792436A}.Release|x86.Build.0 = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|x64.ActiveCfg = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|x64.Build.0 = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|x86.ActiveCfg = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Debug|x86.Build.0 = Debug|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|Any CPU.Build.0 = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|x64.ActiveCfg = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|x64.Build.0 = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|x86.ActiveCfg = Release|Any CPU
{44E22B4C-4280-4329-9A7E-3DEC7D487595}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C5437BE-1C81-49D9-931A-FCA2BC2DA589}
EndGlobalSection
EndGlobal
================================================
FILE: Examples/ExtendingBogus/ExtendingBogus.csproj
================================================
Exenet8.0
================================================
FILE: Examples/ExtendingBogus/ExtensionsForAddress.cs
================================================
namespace ExtendingBogus
{
///
/// Augment the existing DataSet via C# extension method.
///
public static class ExtensionsForAddress
{
private static readonly string[] CanadaDowntownTorontoPostalCodes =
{
"M5S", "M5B", "M5X", "M5V", "M4W", "M4X", "M4Y",
"M5A", "M5C", "M5T", "M5E", "M5G", "M5H", "M5J",
"M5K", "M5L", "M6G"
};
public static string DowntownTorontoPostalCode(this Bogus.DataSets.Address address)
{
return address.Random.ArrayElement(CanadaDowntownTorontoPostalCodes);
}
}
}
================================================
FILE: Examples/ExtendingBogus/ExtensionsForTesting.cs
================================================
using System;
using Newtonsoft.Json;
namespace ExtendingBogus
{
public static class ExtensionsForTesting
{
public static void Dump(this object obj)
{
Console.WriteLine(obj.DumpString());
}
public static string DumpString(this object obj)
{
return JsonConvert.SerializeObject(obj, Formatting.Indented);
}
}
}
================================================
FILE: Examples/ExtendingBogus/FoodDataSet.cs
================================================
using Bogus;
using Bogus.Premium;
namespace ExtendingBogus
{
///
/// The following shows how to create a dedicated DataSet accessible via C# extension method.
///
public static class ExtensionsForFood
{
public static Food Food(this Faker faker)
{
return ContextHelper.GetOrSet(faker, () => new Food());
}
}
///
/// This DatSet can be created manually using `new Candy()`, or by fluent extension method via .
///
public class Food : DataSet
{
private static readonly string[] Candies =
{
"Hard candy", "Taffy", "Chocolate bar", "Stick candy",
"Jelly bean", "Mint", "Cotton candy", "Lollipop"
};
///
/// Returns some type of candy.
///
public string Candy()
{
return this.Random.ArrayElement(Candies);
}
private static readonly string[] Drinks = { "Soda", "Water", "Beer", "Wine", "Coffee", "Lemonade", "Milk" };
public string Drink()
{
return this.Random.ArrayElement(Drinks);
}
}
}
================================================
FILE: Examples/ExtendingBogus/Program.cs
================================================
using Bogus;
namespace ExtendingBogus
{
class Program
{
static void Main(string[] args)
{
var userFaker = new Faker()
//Extend Bogus with a 'new' Food data set; see FoodDataSet.cs
.RuleFor(p => p.FaveCandy, f => f.Food().Candy())
.RuleFor(p => p.FaveDrink, f => f.Food().Drink())
//Extend the existing Address data set with a custom C# extension method; see ExtensionsForAddress.cs
.RuleFor(p => p.PostCode, f => f.Address.DowntownTorontoPostalCode());
var user = userFaker.Generate();
user.Dump();
}
}
public class User
{
public string FaveDrink;
public string FaveCandy;
public string PostCode;
}
}
================================================
FILE: Examples/ExtendingBogus/README.md
================================================
[1]:https://github.com/bchavez/Bogus#the-great-c-example
## Getting Started with Bogus
#### Requirements
* **.NET Core 3.1** or later
#### Description
The `ExtendingBogus` example shows how to extend **Bogus**' APIs in the following ways:
1. Using a custom C# extension method; see `ExtensionsForAddress.cs`.
Augmenting **Bogus**' APIs via C# extension is useful to make APIs cleaner and more suitable for your specific situation.
1. Using a custom data set; see `FoodDataSet.cs`.
Creating a custom data set is useful when categorizing many 'related' APIs together.
To run the example, perform the following commands *inside* this `ExtendingBogus` folder:
* `dotnet restore`
* `dotnet build`
* `dotnet run`
After the `dotnet` commands are successfully executed above, you should see some extended *custom* fake data printed to the console!
```
> dotnet run
```
```json
{
"FaveDrink": "Soda",
"FaveCandy": "Jelly bean",
"PostCode": "M4W"
}
```
================================================
FILE: Examples/GettingStarted/GettingStarted.csproj
================================================
Exenet8.0
================================================
FILE: Examples/GettingStarted/Program.cs
================================================
using System;
using System.Collections.Generic;
using Bogus;
using Bogus.DataSets;
using Bogus.Extensions;
using Newtonsoft.Json;
namespace GettingStarted
{
class Program
{
static void Main(string[] args)
{
//Set the randomzier seed if you wish to generate repeatable data sets.
Randomizer.Seed = new Random(3897234);
var fruit = new[] {"apple", "banana", "orange", "strawberry", "kiwi"};
var orderIds = 0;
var testOrders = new Faker()
//Ensure all properties have rules. By default, StrictMode is false
//Set a global policy by using Faker.DefaultStrictMode if you prefer.
.StrictMode(true)
//OrderId is deterministic
.RuleFor(o => o.OrderId, f => orderIds++)
//Pick some fruit from a basket
.RuleFor(o => o.Item, f => f.PickRandom(fruit))
//A random quantity from 1 to 10
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 10))
//A nullable int? with 80% probability of being null.
//The .OrNull extension is in the Bogus.Extensions namespace.
.RuleFor(o => o.LotNumber, f => f.Random.Int(0, 100).OrNull(f, .8f));
var userIds = 0;
var testUsers = new Faker()
//Optional: Call for objects that have complex initialization
.CustomInstantiator(f => new User(userIds++, f.Random.Replace("###-##-####")))
//Basic rules using built-in generators
.RuleFor(u => u.FirstName, f => f.Name.FirstName())
.RuleFor(u => u.LastName, f => f.Name.LastName())
.RuleFor(u => u.Avatar, f => f.Internet.Avatar())
.RuleFor(u => u.UserName, (f, u) => f.Internet.UserName(u.FirstName, u.LastName))
.RuleFor(u => u.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName))
.RuleFor(u => u.SomethingUnique, f => $"Value {f.UniqueIndex}")
.RuleFor(u => u.SomeGuid, Guid.NewGuid)
//Use an enum outside scope.
.RuleFor(u => u.Gender, f => f.PickRandom())
//Use a method outside scope.
.RuleFor(u => u.CartId, f => Guid.NewGuid())
//Compound property with context, use the first/last name properties
.RuleFor(u => u.FullName, (f, u) => u.FirstName + " " + u.LastName)
//And composability of a complex collection.
.RuleFor(u => u.Orders, f => testOrders.Generate(3))
//After all rules are applied finish with the following action
.FinishWith((f, u) =>
{
Console.WriteLine("User Created! Name={0}", u.FullName);
});
var user = testUsers.Generate(3);
user.Dump();
}
}
public class Order
{
public int OrderId { get; set; }
public string Item { get; set; }
public int Quantity { get; set; }
public int? LotNumber { get; set; }
}
public enum Gender
{
Male,
Female
}
public class User
{
public User(int userId, string ssn)
{
this.Id = userId;
this.SSN = ssn;
}
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName { get; set; }
public string UserName { get; set; }
public string Email { get; set; }
public string SomethingUnique { get; set; }
public Guid SomeGuid { get; set; }
public string Avatar { get; set; }
public Guid CartId { get; set; }
public string SSN { get; set; }
public Gender Gender { get; set; }
public List Orders { get; set; }
}
public static class ExtensionsForTesting
{
public static void Dump(this object obj)
{
Console.WriteLine(obj.DumpString());
}
public static string DumpString(this object obj)
{
return JsonConvert.SerializeObject(obj, Formatting.Indented);
}
}
}
================================================
FILE: Examples/GettingStarted/README.md
================================================
[1]:https://github.com/bchavez/Bogus#the-great-c-example
## Getting Started with Bogus
#### Requirements
* **.NET Core 3.1** or later
#### Description
The `GettingStarted` example is the full working example of [**"The Great C# Example"**][1] on the homepage of this repository.
To run the example, perform the following commands *inside* this `GettingStarted` folder:
* `dotnet restore`
* `dotnet build`
* `dotnet run`
After the `dotnet` commands are successfully executed above, you should see some fake JSON data printed to the console!
================================================
FILE: HISTORY.md
================================================
## v35.6.5
Release Date: 2025-10-25
* PR 622: Adds music and vehicle faker classes to parse method and unit tests. Thanks Perks-of-Being-a-Cauliflower!
## v35.6.4
Release Date: 2025-09-25
* PR 614: Adds Extension Method to generate Iranian National Numbers. Thanks @amirh-p!
* PR 607, 617, 618, 616, 615: General code improvements. Thanks @SimonCropp!
* Issue 619 and PR 620: Replaced defunct Placeholder.com with placehold.co. Image.PlaceholderUrl should work again. Thanks mahmmoudkinawy!
## v35.6.3
Release Date: 2025-04-12
* Issue 601: Fixes `Internet.Avatar()` URL generation. Moves from Cloudflare IPFS to IPFS.io.
* Fixed broken checksum calculation test in `BelgianExtensionTests`.
* .NET SDK 9 now required for builds. Various C# improvements and modernizations. Thanks @SimonCropp!
## v35.6.2
Release Date: 2025-02-20
* PR 584: Pack LICENSE file with NuGet package. Also, use ProjectIcon.
* Issue 581: Fix `Randomizer.ULong()` arithmetic overflow. Thanks @reuterma24!
* PR 586: Use .NET 9 SDK build tooling. Thanks @SimonCropp!
* PR 587: Fix CS1584 incorrect use of cref in XML doc comment. Thanks @SimonCropp!
* PR 589: Unlock ability to use any .NET SDK build tooling on AppVeyor. Thanks @SimonCropp!
## v35.6.1
Release Date: 2024-09-02
* PR 560: Ensure Belgian National Numbers has padded checksum. Thanks @vyruz1986!
## v35.6.0
Release Date: 2024-04-27
* PR 556: Remove obsolete/non-working LoremPixel image service. `Images.LoremPixelUrl()` is removed. Thanks @marijnz0r!
* PR 557: Added `Bogus.Extensions.Belgium` extension methods below. Thanks @vyruz1986!
* Added `f.Person.NationalNumber()` - Rijksregisternummer / Numéro Nationale
## v35.5.1
Release Date: 2024-04-27
* PR 538: Fixes Invalid Costa Rica IBAN format. Thanks @dangerman!
## v35.5.0
Release Date: 2024-03-09
* PR 500: Allows locally set time references for Date calculations instead of global statics. See Faker[T].UseDateTimeReference(), Faker.DateTimeReference, and DataSets.Date.LocalSystemClock. Thanks @garcipat!
## v35.4.1
Release Date: 2024-03-02
* PR 529: XML Docs: Add inclusive / exclusive number ranges documentation for Randomizer. Thanks @Mitchman215!
* PR 535: Fix gender-digit for Swedish Personnummer. Thanks @LarsBergqvist!
## v35.4.0
Release Date: 2024-01-14
* PR 488: Added `Bogus.Extensions.Poland` extension methods below. Thanks Mik1mak!
* Added `f.Person.Pesel()` - Number of Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
* Added `f.Company.Nip()` - Numer identyfikacji podatkowej (NIP)
* Added `f.Company.Regon()` - Number of Rejestr Gospodarki Narodowej (REGON)
* PR 427: Fix incorrect generation for Finnish social security number. Thanks @roeyskoe!
* PR 431: Fix VIN can be longer than 17 character length. Thanks skwasjer!
* PR 421: Add strict VIN charset without I, O, and Q according to NHTSA standard. Thanks skwasjer!
* PR 414: Added `f.Person.Samordningsnummer()` extension method in `Bogus.Extensions.Sweden`. Swedish coordination number. Thanks aschan!
## v35.3.2
Release Date: 2024-01-13
* PR 466: Added `f.Person.Cnp()` extension method in `Bogus.Extensions.Romania`. Generates Romanian Personal Identification number (CNP). Thanks totpero!
## v35.3.1
Release Date: 2024-01-12
* PR 510: Added `f.Finance.VatNumber()` extension method in `Bogus.Extensions.UnitedKingdom`. Generates a UK compatible VAT registration number. Thanks p1971!
## v35.3.0
Release Date: 2024-01-01
* PR 496: Improves Denmark CPR number generator with checksum validation. Thanks @MunroRaymaker and @NielsPilgaard!
## v35.2.0
Release Date: 2023-12-26
* Issue 497: PR 522 - Better Xamarin AOT compatibility. Renames/removes diacritics from API method names Finland: Henkilötunnus -> Henkilotunnus; Norway: Fødselsnummer -> Fodselsnummer.
## v35.0.1
Release Date: 2023-12-11
* PR 513: Update Swedish `sv` locale; first/last names. Thanks @EBD232!
## v34.0.2
Release Date: 2022-03-27
* PR 406, 415: Improve XML documentation. Thanks @danielwagn3r, @DanteDeRuwe
* PR 413: Change access modifier of `Randomizer.localSeed` to protected. Thanks @davermaltby
## v34.0.1
Release Date: 2021-11-22
* PR 399: Add support for .NET 6 DateOnly and TimeOnly random generations in Faker.Date. Thanks @prasadtelkikar!
* Moved Faker[T] extensions .OrNull() and .GenerateBetween() into main Bogus namespace.
* C# 10 and VS 2022 build tooling.
## v33.1.1
Release Date: 2021-08-29
* PR 390: Default Binder changed to allow use of private property setters in base classes. Thanks @thomaslevesque!
## v33.0.2
Release Date: 2021-02-21
* PR 359: Add `Bogus.Person.Personnummer()` Swedish national identity number
## v33.0.1
Release Date: 2021-02-07
* Locale data parity with faker-js@5478d65.
* `nep` locale renamed to `ne`.
* `de` locale; `Date` dataset changed.
* `es` locale; gender names added.
* `fr` locale; `Date` dataset changed.
* `nb_NO` locale; gender names added.
* `nl` locale; `Address`, `Commerce`, `Date`, `Hacker`, `Internet` datasets changed; gender names added.
* `pt_BR` locale; gender names added.
* `tr` locale; gender names added.
* `vi` locale; gender names added. `Date`, `Lorem`, datasets changed.
* Added `Internet.Port()`; generate port numbers from 1 to 65535.
## v32.1.1
Release Date: 2021-01-31
* Minor improvements to XML docs.
* Better exception messages around empty collections and empty arrays.
* PR 339: Fix null reference exception when calling StrictMode(true) on Faker with no rules.
* PR 352: Fix first name generation for locales that don't support gender names.
## v32.0.2
Release Date: 2020-12-12
* Issue 342: Use realistic `pt_BR` city names.
## v32.0.1
Release Date: 2020-11-28
* Issue 336: Fixed `Internet.Avatar()` 403 Forbidden URLs. AWS S3 bucket hosting uifaces.com avatars was disabled. Avatars are now decentrally hosted on IPFS globally and retrieved from Cloudflare's IPFS gateway.
* To help host, pin root CID: Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye
* Browse: https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/
* Details: https://github.com/bchavez/Bogus/issues/336
## v31.0.3
Release Date: 2020-10-03
* Issue 328, 327: Fixed `pt_BR` locale where `Address.City()` threw `ArgumentOutOfRangeException`.
## v31.0.2
Release Date: 2020-09-13, UNPUBLISHED FROM NUGET
* Ensures Bogus Premium datasets load with new `DataSet.Get(category, path)` overload.
## v31.0.1
Release Date: 2020-09-13, UNPUBLISHED FROM NUGET
* Locale data parity with faker-js@91dc8a3.
* Added `Music` dataset with `.Genre()` method.
* Added `Date.TimeZoneString()`.
* Added new Finnish `fi` locale.
* Added new Hrvatski `hr` locale.
* `cz` locale updated.
* `en` locale updated.
* `en_IE` locale updated.
* `en_IND` locale updated.
* `fa` locale updated.
* `fr` locale updated.
* `ja` locale updated.
* `pl` locale updated.
* `pt_BR` locale updated.
* `ru` locale updated.
* `sv` locale updated.
* `vi` locale updated.
* `zh_CN` locale updated.
## v30.0.4
Release Date: 2020-08-15
* Issue 319: The `Random.Decimal()` implementation reverted to previous v29 implementation. Avoids arithmetic `OverflowException` when calling `Random.Decimal(0, decimal.MaxValue)`. The v30 implementation moved to `Bogus.Extensions` namespace as `Random.Decimal2()` which can generate more decimal precision.
## v30.0.3
Release Date: 2020-08-13, UNPUBLISHED FROM NUGET
* Added `f.Address.CountryOfUnitedKingdom()` extension method in `Bogus.Extensions.UnitedKingdom`.
## v30.0.2
Release Date: 2020-08-05, UNPUBLISHED FROM NUGET
* Deterministic sequences may have changed.
* Promoted v30.0.1-beta-4 to v30.0.2 release.
## v30.0.1-beta-4
Release Date: 2020-07-23
* Change credit card `CheckDigitExtension` methods to public
## v30.0.1-beta-3
Release Date: 2020-06-29
* Issue 307: Fixed `Internet.UserAgent()` sometimes generating invalid user agent strings that could not be parsed by `System.Net.Http.HttpRequestMessage.Headers`.
## v30.0.1-beta-2
Release Date: 2020-06-20
* Added `Finance.Litecoin()`.
* Added `Commerce.ProductDescription()`.
* Add PlaceIMG image service. `Image.PlaceImgUrl()`.
* Data parity with faker.js. Deterministic sequences may have changed.
* New `en_NG` Nigerian locale.
* `en` updated.
* `nl_BE` updated.
* `de` updated.
* `ru` updated.
* `zh_CN` updated.
* `zh_TW` updated.
* `ar` updated.
* `cz` updated.
* `es_MX` updated.
* `sk` updated.
* `it` updated.
## v30.0.1-beta-1
Release Date: 2020-06-14
* PR 300: `Random.Number()` now inclusive of `max: int.MaxValue`.
* PR 300: `Random.Even()` better random distribution and range checking.
* PR 300: `Random.Odd()` better random distribution and range checking.
* PR 300: `Random.Int()` bug fixed where `.Int()` may not return `int.MaxValue`.
* PR 300: `Random.Decimal()` with greater decimal precision.
* Deterministic values may have changed.
* Big thank you to @logiclrd for PR 300!
## v29.0.2
Release Date: 2020-04-11
* Minor update to `ru` locale data. Two `ru` city names could appear as one.
## v29.0.1
Release Date: 2020-02-10
* Data parity with faker.js. Deterministic sequences using `Internet.Avatar()` may have changed.
* Add support for .snupkg NuGet Symbol Server Packages via SourceLink.
* Added Randomizer.EnumValues() that makes selecting a subset of enum values easier.
* Modified `.OrNull(f)` extension method signatures for type-safe with nullable primitive types, structs, and reference types via `in` parameter to avoid ambiguous calls.
## v28.4.4
Release Date: 2019-12-10
* PR 272: Add extension method for generating Norwegian national identity numbers. `Person.Fødselsnummer()`. Thanks @mika-s!
## v28.4.3
Release Date: 2019-12-03
* Issue 271: Minor bug fix in Brazil `Person.Cpf()` extension method. Previously, only the first call to `Person.Cpf(includeFormatSymbols)` respected the `includeFormatSymbols` parameter due to the final result being saved in `Person` context. `Person.Cpf()` now respects the `includeFormatSymbols` parameter after subsequent repeat calls to `Cpf()` with the same `Person`. Thanks for testing @ArthNRick!
## v28.4.2
Release Date: 2019-11-30
* PR 269: Adds `includeFormatSymbols` parameter to include or exclude formatting characters for Brazil `Person.Cpf()` and `Company.Cnpj()` extension methods.
## v28.4.1
Release Date: 2019-10-14
* Issue 260: Improved social security number (SSN) generation that should pass basic validation by avoiding invalid SSN ranges. Note: Deterministic SSNs generated with `Person.Ssn()` will change.
* Issue 252: `Internet.Ip()` now avoids generating IP addresses with a leading zero. For example, Bogus will not generate an IP address with a leading zero like 0.1.2.3. Note: Deterministic IPs generated with `Internet.Ip()` will change.
* PR 261: Added `Internet.IpAddress()`, `Internet.Ipv6Address()`, `Internet.IpEndPoint()`, and `Internet.Ipv6EndPoint()`.
* Issue 258: Add `Internet.UrlRootedPath()` to generate random `/foo/bar` paths.
* Added `Internet.UrlWithPath(fileExt:".txt")` fileExt extension parameter to generate URLs with a specific file extension.
## v28.3.2
Release Date: 2019-10-04
* PR 259: Fixes `.GenerateForever(ruleset)` to use ruleset parameter when supplied as argument. Thanks @StanleyGoldman!
## v28.3.1
Release Date: 2019-09-20
* Issue 255 / PR 256: Allows interfaces with `Faker` using `Faker.CustomInstantiator(f => new Foo())`. Thanks Rowland!
## v28.2.1
Release Date: 2019-09-10
* Added `Faker.RuleFor(string, (f, t) => )` overload.
* Internal re-factoring `.RuleFor` overload logic. Simplified overload call chain.
* Internal `Faker.RuleForInternal()` renamed to `Faker.AddRule()`
## v28.1.1
Release Date: 2019-09-09
* Issue 253, PR 254: New rule overload for `Faker.RuleFor('string',...)`. Helps cases that require rules for protected or hidden members of `T`.
## v28.0.3
Release Date: 2019-08-28
* Issue 249: Fixed `Internet.Url()` including spaces in domain names for `pt_BR` locale or any locale with compound first names that may contain spaces. Thanks RodrigoRodriguesX10!
* PR 241: General code quality improvements in `DataSets.System`. Better XML docs and lower array allocations. Thanks bartdebever!
* PR 245: XML doc improvements to `DataSets.Lorem`. Thanks bartdebever!
## v28.0.2
Release Date: 2019-07-07
* PR 235: Added `Bogus.DataSets.Vehicle.GbRegistrationPlate()` in `Bogus.Extensions.UnitedKingdom` extension namespace to generate GB registration plates. Thanks @colinangusmackay.
## v28.0.1
Release Date: 2019-07-02
* BREAKING: Deterministic sequence values may have changed for fake email addresses derived from `Internet.Email()` or `Internet.UserName()` in locales other than `en`.
* Issue 229: Adds `Finance.Iban(countryCode)` ISO3166 country code parameter. Allows generating IBAN codes for specific countries. The country code must be a supported otherwise an exception is thrown.
* Issue 225: Better support for transliteration of international Unicode characters to US-Latin/Roman ASCII character sets. `Internet.Email()` and `Internet.UserName()` are more respectful of specified locale using character transliteration.
* Added `.Transliterate()` string extension method in `Bogus.Extensions` namespace.
* Added `Internet.UserNameUnicode()` that preserves Unicode characters in user names.
* Minor performance improvement to `Utils.Slugify` using compiled Regex.
* Issue 232: Adds `.OrNull[T]() where T : struct` overload which makes it easier to work with nullable types without type casting.
* Added `defaultValue` parameter to `.OrDefault(f, weight, defaultValue)` that can default to a different value than the `default` keyword.
## v27.0.1
Release Date: 2019-05-02
* Issue 218: Fixed bug that prevented global static `Faker.DefaultStrictMode` from working.
* Issue 210: Added `Randomizer.Utf16String` that generates technically valid Unicode with paired high/low surrogates.
* Added `placeholder.com` image service.
## v26.0.2
Release Date: 2019-03-22
* New `Person(seed)` constructor for seeding person objects by integer. Thanks @sgoguen!
* Fixed `Person.DateOfBirth` not using `Date.SystemClock` as 'now' reference.
## v26.0.1
Release Date: 2019-02-26
* Data and feature parity with faker.js @ d3ce6f1
* New `Vehicle` data set added.
* `en_IND` state abbreviations and state names updated.
* `en_CA`, `fr_CA` improved Canadian postal codes.
* `pt_PT` locale updated with new and changed data.
* `en` company names updated.
* `pt_PT` locale updated.
* Minor bug in `Date.Weekday` and `Date.Month` that could cause locale weekday/month values to default to `en`.
* Note: deterministic sequences may have changed.
## v25.0.4
Release Date: 2019-01-17
* PR 194: Update Dutch `nl` locale with extra `name.first_name`, `address.street_suffix`, and `company.suffix`.
## v25.0.3
Release Date: 2019-01-06
* Added `f.Images.LoremFlickrUrl()` (https://loremflickr.com) image service.
* Issue 193: Turkish :tr: state/providence names added to 'tr' locale.
## v25.0.2
Release Date: 2018-12-11
* Issue 192: Fixed IndexOutOfRangeException when `Company.CompanyName()` is used with `az` locale.
## v25.0.1
Release Date: 2018-11-27
* Add SourceLink compatibility with Visual Studio 2017.
* Obsoleted **LoremPixel.com** `Image` categories. The image service is usually down or very slow. Consider using `Images.PicsumUrl()` as a replacement. This version is an obsolete-warn, next release will have Image category APIs removed.
## v24.3.1
Release Date: 2018-11-03
* `tr` - Turkish locale first/last names updated. Lorem data set updated. Thanks ahmetcanaydemir!
* Added `f.Image.PicsumUrl` (https://picsum.photos) service as faster alternative to Lorem Pixel.
## v24.3.0
Release Date: 2018-10-02
* Data / feature parity with faker.js @ 9dd5a52
* `af_ZA` - New South Africa (Afrikaans) locale added.
* `zu_ZA` - New South Africa (Zulu) locale added.
* `en_ZA` - South Africa (English) locale updated
* `ru` - Russian locale updated.
* `id_ID` - Indonesia locale updated.
* `es` - Spanish locale updated.
* `f.Images.DatUri` now accepts an HTML color parameter.
* PR 180: Resolved Turkish Culture `.ToLower` causing invalid JSON dataset path `.ToLowerInvariant` now used.
## v24.2.0
Release Date: 2018-09-27
* Issue 179: Fixed regression introduced in 23.0.3 that forbid setting of internal/non-public members of `T` in when `Faker` is used.
## v24.1.0
Release Date: 2018-09-26, UNPUBLISHED FROM NUGET
* Added `nullWeight` parameter to `.OrNull()` extension method for weighted generation of null values.
* Added new `.OrDefault()` extension method. Thanks @anorborg!
## v24.0.0
Release Date: 2018-09-26, UNPUBLISHED FROM NUGET
* BREAKING: Deterministic values may have changed. Parity with **faker.js** @ 07f39bd3.
* `en_ZA` - South Africa (English) locale added.
* `fr_CH` - French (Switzerland) locale added.
* `pl` locale "phone numbers" updated.
* `sv` locale "names" section updated.
* `en`, `de`, `de_AT` "names" section updated.
* Added `f.Commerce.Ean8` EAN-8 product barcode number generator.
* Added `f.Commerce.Ean13` EAN-13 product barcode number generator.
## v23.0.3
Release Date: 2018-08-29, UNPUBLISHED FROM NUGET
* PR 170: Faster `Faker[T].Generate()` with setter cache. Approx 1.7x speedup. Thanks Mpdreamz!
## v23.0.2
Release Date: 2018-08-13
* BREAKING CHANGE: Deterministic sequence values may have changed. Unit tests expecting specific values may be different if `Bogus.Person` is used.
* Issue 168: Added `Bogus.Person.Address.State` field.
* Issue 139: Added `Date.SystemClock` static property for setting global time Bogus uses for date calculations.
* Issue 169: `Date.Weekday()` should return a weekday not a month.
## v22.3.2
Release Date: 2018-07-18
* Added `f.Random.Guid()` for better GUID discoverability.
* PR 164: Added new Tax ID extensions `Person.Nif()` and `Company.Nipc()` for Portugal. Thanks JoseJr!
## v22.3.1
Release Date: 2018-07-05
* PR 159: Add UK National Insurance Number `f.Finance.Nino()` in `Bogus.Extensions.UnitedKingdom`. Thanks mortware!
* PR 160: `DateTimeOffset` support added to `f.Date` dataset. Methods are suffixed by "Offset". IE: `f.Date.SoonOffset`. Thanks Simon!
* Added `refDate` parameter to `f.Date.Soon` and `f.Date.Recent`.
* `f.Date.Between(start, end)` now respects `DateTimeKind.Utc`.
## v22.2.1
Release Date: 2018-06-29
* PR 153: Possible breaking changes: Minor typo & spelling corrections made to some parameter names. Thanks for the corrections Simon!
## v22.1.4
Release Date: 2018-06-26
* PR 151: Added `Bogus.Distributions.Gaussian` namespace for numerical Normal Distribution generated values! Thanks codersg!
* Added `uniqueSuffix` parameter to `Internet.Email()` to help with unique email constraints.
## v22.1.3
Release Date: 2018-06-14
* PR 149: Added new Arabic 'ar' locale. Thanks Saied!
* PR 148: Fixed `.FullName()` for locales where both first/last name have genders. Thanks binarycode!
## v22.1.2
Release Date: 2018-05-29
* Improved XML documentation comments on `Faker[T]` API.
## v22.1.1
Release Date: 2018-05-20
* PR 144: Argument support for mustache handlebars. Example: `{{name.firstname(Male)}}`
* Using **C# 7.3** generic `Enum` constraints for methods that only accept enums. Example: `f.PickRandom()`.
## v22.0.9
Release Date: 2018-05-17
* Issue 143: Fixed rare case when `f.IndexGlobal` could be zero twice at start of generation.
* Fixed typo in XML docs.
## v22.0.8
Release Date: 2018-04-09
* New `Company.Ein()` to generate employer identification numbers.
* Preparing release of extended data sets for Bogus.
## v22.0.7
Release Date: 2018-04-01
* New `Internet.Color()` format options: CSS `rgb(...)` and delimited RGB.
* New `System.AndroidId()` to generate GCM registration ID.
* New `System.ApplePushToken()` to generate a random Apple Push Token.
* New `System.BlackBerryPin()` to generate a random Black Berry PIN.
* New `Randomizer.Hash()` to generate random hashes of specified length.
* New `Randomizer.String2()` to generate random strings with specified character sets.
## v22.0.6
Release Date: 2018-03-29
* Added `Randomizer.String` method to generate strings. Uses `Chars()` method.
* PR 136: Improve speed of `DataSet.ParseTokens()`. Thanks @danij!
## v22.0.5
Release Date: 2018-03-02
* Bogus now throws exceptions for locales it doesn't recognize. Improves developer experience.
* New extension method `.ToBogusLocale()` on `System.Globalization.CultureInfo` to help translate from **.NET** locale codes to **Bogus** locale codes.
## v22.0.3
Release Date: 2018-02-27
* Generate more realistic Bitcoin addresses.
* New extension method `Faker.GenerateBetween(min, max)` that generates N objects between `min` and `max`. Located in `Bogus.Extensions`. N should be considered non-deterministic but technically depends on the parameters each time this extension method was called.
* Added `Lorem.Paragraphs(min, max)` overload.
* Added improved XML doc comments and parameter names on `Lorem.Paragraph`.
* UK extension method `.ShortCode()` renamed to `.SortCode()` as originally intended.
* Marked `DataSet.Get/.GetObject/BObject` methods as `protected internal`. Reducing API surface noise.
* Added new `.OrNull` in `Bogus.Extensions` to help create randomly null values. Example: `.RuleFor(x=>x.Prop, f=>f.Random.Word().OrNull(f))`.
* New groundwork for extending Bogus with premium (paid) data sets and tooling.
## v22.0.2
Release Date: 2018-01-05
* Issue 121: Fixes the inability to `.Ignore(...)` a property or field after a rule had already been set.
## v22.0.1
Release Date: 2017-12-23
* Issue 120: `.Generate(n)` now returns `List` instead of `IList`.
* Added `f.Address.CountryCode()` ISO 3166-1 alpha-3 country code generator.
* New `Bogus.Extensions.Extras` namespace for generally useful helper methods.
* Added `Finance.CreditCardNumberObfuscated()` extension to `Bogus.Extensions.Extras` namespace.
* Moved credit card `CheckDigit()` extensions to `Bogus.Extensions.Extras` namespace.
## v21.0.5
Release Date: 2017-12-16
* Better error support.
* Added `Person.FullName` field.
* Allowed `Faker.FinishWith` to be called multiple times. Last call wins.
## v21.0.4
Release Date: 2017-12-13
* Fixed `f.Image` URL generation.
## v21.0.2
* Re-enabled **.NET Standard 1.3** targeting.
* Added `Gender` field to `Person`. Deterministic sequences may have changed.
* Added `Randomizer.Bool(weight)` to generate weighted boolean values of true.
* Italian `CodiceFiscale()` extension method added. Extends `Person` and `Finance`.
## v20.0.2
Release Date: 2017-11-06
* Fixed Issue 102: `f.Random.Uuid()` is now deterministic based on global or local seed.
## v20.0.1
Release Date: 2017-11-04
* Added `Faker.Clone()`: Clones internal state of a `Faker` and allows for complex faking scenarios and rule combinations.
* Added `Faker.UseSeed(n)`: Allows you to specify a localized seed value on a `Faker` instead of a global static `Randomizer.Seed`.
* Stronger `Seed` determinism for multi-threaded scenarios.
## v19.0.2
Release Date: 2017-11-01
* Fixed #99: Possible threading issue that can cause `System.ArgumentException`.
## v19.0.1
Release Date: 2017-10-26, UNPUBLISHED FROM NUGET
* Using new BSON binary data format for locales.
* Removed dependency on Newtonsoft.Json!
* Locale Updates -
* `fr`: new street address prefixes.
* `fa`: new street addresses.
* `pl`: removed 2008 value from city.
* `en`: new gender first names
* New Dutch (Belgium) `nl_BE` locale.
* New Romanian `ro` locale.
* Added `f.Finance.RoutingNumber` - Generates an ABA routing number with valid check digit.
* Added `Faker.GenerateForever` that returns `IEnumerable` with unlimited generated items when iterated over.
* Added United Kingdom extension method to generate bank ShortCodes on `f.Finance.ShortCode()`.
* Re-ordered adjective and buzz in the `f.Company.Bs` for a correct gramatics.
* Added `f.Address.Direction`. Generates cardinal or ordinal directions.
* Added `f.Address.CardinalDirection`. Generates "North", "South", etc.
* Added `f.Address.OrdinalDirection`. Generates "Northeast", "Southwest", etc.
## v18.0.2
Release Date: 2017-09-14
* Issue 86: Removed diacritic mark/accents (á, í, ó, ú, etc) from generated email addresses and user names.
* Added `string.RemoveDiacritics` helper method.
## v18.0.1
Release Date: 2017-09-13
* Fixed bug in Finland's `f.Person.Henkilötunnus` personal identity code generator that sometimes produced 11 characters.
* Added `f.Finance.Ethereum`. Generate an Ethereum address.
* Added `f.Finance.CreditCardCvv`. Generate a random credit card CVV number.
* Improved `f.Finance.CreditCardNumber`. Generate a random credit card number.
* Added `f.Random.Hexadecimal`. Generates a random hexadecimal string.
* Added `f.System.DirectoryPath`. Generates a random directory path.
* Added `f.System.FilePath`. Generates a random file path.
* Added `f.Date.Soon`. Generates a date and time that will happen soon.
* Added `f.Random.ArrayElements`. Gets a random subset of an array.
* Added `f.Random.ListItems`. Gets a random subset of a list.
* Added `f.Company.Cnpj` extension method for Brazil. Generates Brazilian company document.
* Improved `f.PhoneNumbers`. More realistic US phone numbers.
* Improved `f.Address.Latitude/Longitude` with min and max parameters.
* Minimum for `f.Commerce.Price` is now $1.00 (not zero).
* Reduced assembly size by removing redundant locale data.
* Locale updates:
* `en_AU` - Update Australian postcode ranges.
* `en_IND` - Indian postcodes are always numeric.
* `ru` - Word corrections.
## v17.0.1
Release Date: 2017-08-24
* Migration to **.NET Standard 2.0**.
## v16.0.3
Release Date: 2017-08-24
* With additional overloads for `.PickRandom(IList)` and `.PickRandom(ICollection)` we can now add `.PickRandom("cat", "dog", "fish")` back to the API.
## v16.0.2
Release Date: 2017-08-23
* BREAKING CHANGE: `Faker.Generate(n)` now calls `.ToList()` under the hood to escape LINQ deferred execution. Remembering to call `.ToList()` after `.Generate(n)` was a sticking point for new users writing test assertions on generated values. Please do not call `Faker.Generate(n).ToList()` as it would execute `.ToList()` twice. Simply, `Faker.Generate(n)` is enough.
* `f.Generate` and `f => f.Make` now return `IList` to signify the breaking change above.
* Issue #92: Added `.GenerateLazy` to keep old behavior and returns `IEnumerable`.
* Issue #93: Renamed a `PickRandom` overload to avoid the compiler from picking wrong `PickRandom` method.
* Added `f.PickRandomParam("cat","dog","fish")`.
* Removed `[Obsolete]` methods.
## v15.0.7
Release Date: 2017-08-20
* Issue #88 - API aesthetics: Added `Name.FullName()` convenience method to generate a full name.
## v15.0.6
Release Date: 2017-08-02
* PR #87: Added `.Rules()` method on `RuleSet`. Thanks @digitalcyote.
## v15.0.5
Release Date: 2017-07-28
* Add parameter for including `Currency` fund codes (BOV, CLF, COU, MXV, UYI).
* Fixed minor issue in `Person.Email` having duplicate names.
* Helper method: `f.PickRandomWithout(ExcludeItem1, ExcludeItem2)` added.
* Helper method: `f.PickRandom("cat", "dog", "fish")` added.
* Performance: 40% reduction in Bogus' DLL size and memory footprint by removing whitespace in **Json** data files.
* Newtonsoft dependency update 10.0.3.
## v15.0.3
Release Date: 2017-05-06
* Added `f => f.Rant` to generate random user content like product reviews.
* Added `new Faker[T].Rules( (f, t) => ...)` as a shortcut for building rules quickly.
* Added `Address.FullAddress`
* Added `Internet.UrlWithPath` allowing to create URLs with random paths.
* Added `ru` (Russian locale) hacker adjective, ing-verb, noun, and verb.
* Added `Internet.Mac` address separator parameter.
* Feature parity with **faker.js** @ 6cdb93ef...
* Using new C# 7 features. =)
## v15.0.1
Release Date: 2017-04-11
* Building with Visual Studio 2017.
* Issue 70: Fixed `ArgumentException` that occurs with derived hidden `new` properties.
## v12.0.2
* `f => f.Generate(n, i => ...)` overload allows use of index when using `f.Generate`.
## v12.0.1
Release Date: 2017-03-27
* PR 64: Improved `.PickRandom(IEnumerable)` performance. Thanks @chuuddo.
* Added `"string".ClampLength(max,min)` extension method to clamp length of strings between min and max.
* Issue 67: Fixed `Randomizer.Int(int.MaxValue, int.MinValue)` range overflow not returning random `int32` values.
## v11.0.5
Release Date: 2017-03-20
* Compatibility with `Newtonsoft.Json` v10.0.1
## v11.0.4
Release Date: 2017-03-14
* Added `.RuleFor(x.Item, "foo")`. Eliminates ceremony of `f =>` for simple values.
## v11.0.3
Release Date: 2017-03-13
* Added range option to `Sentence`.
## v11.0.2
Release Date: 2017-02-23
* New Feature: Allow implicit and explicit type casts: `Order o = orderFaker` and `var o = (Order)orderFaker` without having to call `orderFaker.Generate()`.
## v11.0.1
Release Date: 2017-02-21
* Added `IndexGlobal` alias for `UniqueIndex`.
* Added `IndexFaker` for uniqueness in Faker[T] lifetime.
* Added `IndexVariable` a developer controlled index convenience variable.
* Added `Database` dataset to `f => f.Database` facade.
* Fixed Issue 57 - Avoid unexpected behavior with Parent-Child generators using `UniqueIndex`.
* Removed some `Internet.Avatars` that returned 404.
* Reached feature/data parity with `faker.js` v4.1.0.
## v10.0.1
Release Date: 2017-02-18
* `Internet.UserAgent` - Generates browser user agent strings.
* `Internet.Password` - Generates user passwords using regex.
* Added `az`/Azerbaijani locale.
* Disallow `/` character in `System.FileName`.
* `Helpers.Slugify` properly replaces spaces with `-` dashes.
* `Lorem.Slug` slugs some lorem text.
* `Finance.Iban` - Generates International Bank Account Numbers (IBAN).
* `Finance.Bic` - Generates Bank Identifier Code (BIC) codes.
* `Random.WeightedRandom` - Returns a weighted random distribution of items.
* Allow `https://` in random images.
* `Images.DataUri` - Generates "data:image/svg" URI with width and height.
* `Database` data set for generating column, collation, type stuff.
## v9.0.2
Release Date: 2017-01-19
* Bug: Issue 54: Work around for Visual Studio IntelliSense.
## v9.0.1
Release Date: 2017-01-18
* New Feature: Bogus is now a signed assembly; PublicToken: fa1bb3f3f218129a
## v8.0.4
Release Date: 2017-01-16
* New Feature: Added `PickRandom(IEnumerable)` overload. Thanks joleharkes.
## v8.0.3
Release Date: 2016-12-20
* New Feature: `RuleForType(typeof(string))` allows bulk/default for a particular type on a class. Useful for very large classes with a specific type.
## v8.0.2
Release Date: 2016-12-07
* Issue 46. Fixed threading deadlock situation with static faker initialization. Thanks Mpdreamz.
* Added `f => f.Generate(count, ()=> f.Phone.PhoneNumber())` helper for better fluency when filling properties with `List` of `T`.
## v8.0.1
Release Date: 2016-11-25
* Added `pt_PT` Portuguese (Portugal) locale.
## v8.0.1-beta-1
Release Date: 2016-10-22
* Allow `Faker.RuleFor` rules to be overridden. Last set rule wins.
## v7.1.7
Release Date: 2016-10-11
* `Faker.AssertConfigurationIsValid` to help in unit testing scenarios.
* Add `Internet.Ipv6` method to generate IPv6 addresses.
## v7.1.6
Release Date: 2016-08-07
* Added `f => f.Commerce` on `Faker`.
## v7.1.5
Release Date: 2016-07-27
* Added `cz`/Czech locale
* Updated `en`, `nl`, `pl`, `sk`, `sv` locales.
* Realistic Dutch city naming
* `Randomizer.AlphaNumeric` added.
* `Randomizer.Double` now accepts `(min,max)` arguments
* Added convenience `Randomizer` for random `Decimal`, `Float`, `Byte`, `Bytes`, `SByte`, `Int`, `UInt`, `ULong`, `Long`, `Short`, `UShort`, `Char` and `Chars`.
## v7.1.4
Release Date: 2016-07-06
* Newtonsoft Json 9.0.1 dependency support.
## v7.1.3
Release Date: 2016-06-27
* :boom: .NET Core 1.0 RTM Support.
## v7.1.3-beta-1
Release Date: 2016-05-20
* Compatibility with .NET Standard 1.3 and .NET Core RC2.
## v7.1.2
Release Date: 2016-05-16
* Roll-up Release for .NET Framework since last non-beta release.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v7.1.2-beta-1
Release Date: 2016-05-16
* Clamp Randomizer maximum value to int.MaxValue.
## v7.1.1
Release Date: 2016-05-15
* Roll-up Release for .NET Framework since last non-beta release.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v7.1.1-beta-1
Release Date: 2016-05-15
* Locale update
* Date.Recent(0) generates random times for current date between midnight and now.
* New `System` data set for generating fake file names and mime-types.
* Added `Date.Timespan` for random timespan values.
* Added `System.Semver` for random semantic versions.
* Added `System.Version` for random System.Version objects.
* Added `Internet.ExampleEmail` for simple @example.com email generation.
* Added `Finance.BitcoinAddress` for random bitcoin addresses.
* BREAKING: Fake "seeded" data generated by Bogus may be different from previous versions.
* WARN: Address.City may have changed in some random seeds
## v6.1.1
Release Date: 2016-03-29
* Roll-up Release for .NET Framework since last non-beta release.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v6.1.1-beta-1
Release Date: 2016-03-29
* Fixed index out of bounds bug in faker.Random.Word().
* Commerce.Department output may have changed as a result of this fix.
## v5.1.1-beta-3
Release Date: 2016-03-23
* Removed RuleFor(x = x.Prop, constantValue), was confusing the API.
* Added 0-arity RuleFor(x = x.Prop, () => someValue)
## v5.1.1-beta-2
Release Date: 2016-03-22
* Make f.UniqueIndex as int for convenience.
* Use generic RuleFor(x = x.Prop, constantValue).
## v5.1.1-beta-1
Release Date: 2016-03-21
* New RuleFor(x = x.Prop, constantValue)
* Support for Hashids.net: RuleFor(x = x.Id, f = f.Hashids.Encode())
* New f.UniqueIndex, useful for composing property values that require uniqueness.
## v5.0.1
Release Date: 2016-02-25
* Roll-up Release for .NET Framework since v4.0.1.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v5.0.1-beta-2
Release Date: 2016-02-25
* JvanderStad PR15: Lazy load Person. Avoids extra Seed.Next calls that may interfere with seeded content.
* JvanderStad PR16: Better address generation. Respects locale address formats.
* Added "dotnet5.4" moniker support.
* BREAKING: Fake "seeded" data generated by Bogus may be different from previous versions.
## v4.0.1
Release Date: 2016-02-15
* Roll-up Release for .NET Framework since v3.0.6.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v4.0.1-beta-1
Release Date: 2016-02-15
* Bogus - Feature parity with faker.js.
* System module added. Generate random file names and extensions.
* Randomizer - Added Uuid().
* Locales Updated: en_GB, sv, sk, de_CH, en.
* Locales Added: id_ID, el, lv.
* Prevent apostrophes in return value of Internet.DomainWords
* Added more parameters for Image data set.
* BREAKING API METHODS:
* Lorem - Better API methods: Seeded tests based on "content" will fail due to upgrade.
## v3.0.6
Release Date: 2016-01-21
* Roll-up Release for .NET Framework since v3.0.5.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v3.0.6-beta-1
Release Date: 2016-01-21
* Issue #13: Fixed StrictMode to exclude private fields.
* New Feature: Ignore property or field in StrictMode: Faker[Order].Ignore(o => o.OrderId).
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v3.0.5
Release Date: 2016-01-20
* Roll-up Release for .NET Framework since v3.0.4.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v3.0.5-beta-4
Release Date: 2016-01-19
* Issue #13: StrictMode() now ignores read-only properties.
* Newtonsoft.Json v8 compatibility.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v3.0.5-beta-3
Release Date: 2016-01-18
* Issue #12: Make Bogus thread-safe on Generate() and DataSets. Avoids threading issues in test runners.
* CoreCLR users please continue using latest beta release until CoreCLR is RTM.
## v3.0.5-beta-2
Release Date: 2016-01-11
* CoreCLR support (CoreCLR users please continue using latest beta release until CoreCLR is RTM.).
## v3.0.4
Release Date: 2015-12-10
* Issue 10: Make Bogus work with fields also, not just properties. Fixes LINQPad issues.
## v3.0.3
Release Date: 2015-12-09
* PR 9: quantumplation - Fixed typo in Lorem.Sentance() -> Lorem.Sentence()
## v3.0.2
Release Date: 2015-11-24
* Generate US: SSN - Social Security Numbers.
* Generate Canada: SIN - Social Insurance Numbers.
* Generate Brazil: Cadastro de Pessoas Fisicas - CPF Numbers.
* Generate Finland: Henkilotunnus - Person ID numbers
* Generate Denmark: Det Centrale Personregister - Person ID numbers.
* Allow exclude values on Randomizer.Enum.
* Randomizer.Replace accepts '*' replace with letter or digit.
* Added Lorem.Letter(num).
* Can switch locale on Name: f.Name["en"].LastName()
## v3.0.1
Release Date: 2015-10-22
* Added debug symbols to symbolsource.org.
* PR#6: Fixed lastname and empty list exception -salixzs
* Switch to semantic versioning at par with FakerJS.
## v3.0.0.4
* Adding generators: Date.Month(), Date.Weekday()
* Sentences using lexically correct "A foo bar."
* Added Spanish Mexico (es_MX) locale.
## v3.0.0.3
Release Date: 2015-07-21
* Issue #2: Use latest Newtonsoft.Json 7.0.0.0 -Mpdreamz
## v3.0.0.2
Release Date: 2015-07-11
* Includes Ireland (English) locale.
## v3.0.0.1
Release Date: 2015-07-11
* Migrated to new FakerJS datafile format. Build system uses gulp file to directly import FakerJS locales.
* Faker.Parse() can now tokenize and replace handlebar formats.
* Added Faker.Hacker and Faker.Company properties.
* Added Custom separator on Lorem.Paragraph.
* Added Canada (French) (fr_CA) locale.
* Added Ukrainian (uk) locale.
* Added Ireland (en_IE) locale.
* Added Internet.Mac for mac addresses.
* Support for Canadian post/zip codes.
* Exposed Name.JobTitle, Name.JobDescriptor, Name.JobArea, Name.JobType
* Exposed Address.CountryCode
* Replace symbols in domain words so it generates output for all locales
* Support for gender names, but only for locales that support it. Russian('ru') but not English('en').
* Corrected abbreviation for Yukon to reflect its official abbreviation of "YT".
## v2.1.5.2
Release Date: 2015-06-22
* Fixed instantiating a Person in a non-US locale. -antongeorgiev
## v2.1.5.1
Release Date: 2015-06-11
* Added Georgian, Turkish, and Chinese (Taiwan) locales.
* Added Name.JobTitle()
* Added Internet.Url() and Internet.Protocol().
* Sync'd up with faker.js v2.1.5.
## v2.1.4.2
Release Date: 2015-06-11
* Fixed bug in Faker.Person and Faker[T] that generates new person context after every new object.
* Added support for .FinishWith() for post-processing that runs after all rules but before returning new instance.
* Added Newtonsoft.Json as NuGet dependency.
## v2.1.4.1
Release Date: 2015-06-10
* Minor changes, mostly XML doc update and Person moved from DataSet to Bogus namespace.
## v2.1.4
Release Date: 2015-06-08
* Initial port from faker.js 2.1.4.
================================================
FILE: LICENSE
================================================
MIT License
Bogus - Copyright (c) 2015 Brian Chavez
* http://github.com/bchavez/Bogus
* http://bchavez.bitarmory.com
faker.js - Copyright (c) 2014-2015 Matthew Bergman & Marak Squires
http://github.com/marak/faker.js/
faker.js was inspired by and has used data definitions from:
Copyright (c) 2007-2010 Benjamin Curtis
https://github.com/stympy/faker/
Copyright 2004-2005 by Jason Kohles
http://search.cpan.org/~jasonk/Data-Faker-0.07/
Copyright (c) ZZZ Projects Inc. 2014 - 2016
https://github.com/zzzprojects/Z.ExtensionMethods/
Copyright (c) 2015 kernys
https://github.com/kernys/Kernys.Bson
Copyright (c) 2015 Victor Quinn
https://github.com/chancejs/chancejs
Copyright (c) 2014 Chris Veness
https://github.com/chrisveness/geodesy/
Copyright (c) 2013, Richard Morris
https://github.com/domaindrivendev/Swashbuckle/blob/master/LICENSE
Copyright (c) 2012 Daniele Faraglia
https://github.com/joke2k/faker/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================================================
The BSD 3-Clause License (BSD3)
Copyright (c) 2013-2017 Sascha Droste
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: README.md
================================================
[](https://www.nuget.org/packages/Bogus/) [](https://ci.appveyor.com/project/bchavez/bogus) [](https://twitter.com/intent/tweet?text=Simple%20Fake%20Data%20Generator%20for%20.NET:&url=https%3A%2F%2Fgithub.com%2Fbchavez%2FBogus) [](https://github.com/bchavez/Bogus/discussions)
Bogus for .NET: C#, F#, and VB.NET
======================
Project Description
-------------------
Hello. I'm your host **[Brian Chavez](https://github.com/bchavez)** ([twitter](https://twitter.com/bchavez)). **Bogus** is a simple fake data generator for **.NET** languages like **C#**, **F#** and **VB.NET**. **Bogus** is fundamentally a **C#** port of [`faker.js`](https://github.com/faker-js/faker.js/)
and inspired by [`FluentValidation`](https://github.com/JeremySkinner/FluentValidation)'s syntax sugar.
**Bogus** will help you load databases, UI and apps with fake data for your testing needs. If you like **Bogus** star :star: the repository and show your friends! :smile: If you find **Bogus** useful consider supporting the project by purchasing a [**Bogus Premium**](#bogus-premium-extensions) license that gives you extra **Bogus** superpowers! :dizzy: :muscle: You can also [sponsor the project here](https://github.com/sponsors/bchavez)! :moneybag: :dollar:
### Download & Install
**Nuget Package [Bogus](https://www.nuget.org/packages/Bogus/)**
```powershell
Install-Package Bogus
```
Minimum Requirements: **.NET Standard 1.3** or **.NET Standard 2.0** or **.NET Framework 4.0**.
##### Projects That Use Bogus
* [**Bitwarden Passwordless Server**](https://github.com/bitwarden/passwordless-server) [[code]](https://github.com/bitwarden/passwordless-server/blob/147e0ffa6e687634edcda7ac89518eab56936835/tests/Api.IntegrationTests/Helpers/User/UserHelpers.cs#L12-L22)
* [**Elasticsearch .NET Client (NEST)**](https://github.com/elastic/elasticsearch-net) [[code]](https://github.com/elastic/elasticsearch-net/tree/82c938893b2ff4ddca03a8e977ad14a16da712ba/src/Tests/Framework/MockData)
* [**FluentValidation**](https://github.com/FluentValidation/FluentValidation) [[code]](https://github.com/FluentValidation/FluentValidation/search?q=Bogus)
* [**Microsoft Windows-XAML / Template10**](https://github.com/Windows-XAML/Template10) [[code]](https://github.com/Windows-XAML/Template10/blob/beed5e58a4f8ab381cff6f063d2a91db5b4fc3bc/Basics/PrismSample/Services/DataService.cs#L1)
* [**Microsoft Learning / Cloud-Native Applications Using Microsoft Azure Cosmos DB**](https://github.com/MicrosoftLearning/dp-420-cosmos-db-dev) [[code]](https://github.com/MicrosoftLearning/dp-420-cosmos-db-dev/blob/fdbb3811c20a601fdfda8ea04c9c7de89b8afb19/instructions/08-sdk-bulk.md)
* **Microsoft Office Developer**
* [**Office 365 Development Training Content**](https://github.com/OfficeDev/TrainingContent) [[code]](https://github.com/OfficeDev/TrainingContent/blob/0b2579517f0271f9a64f613b2046ab2821a73956/Teams/03%20Authentication/LabFiles/Starter/officedev-talent-management/DataModel/PositionCandidateData.cs)
* [**Microsoft Teams Sample Connector**](https://github.com/OfficeDev/microsoft-teams-sample-connector-csharp) [[code]](https://github.com/OfficeDev/microsoft-teams-sample-connector-csharp/blob/8805bb1acb136949905e4644c4e714dd7b70a61a/TeamsToDoAppConnector/Utils/TaskHelper.cs)
##### Featured In
* [**Amazon AWS .NET Open Source Fund Recipient - Oct. 1st, 2024**](#sponsors)
* [**Microsoft 'On .NET Live': Next-level EF Core Data Seeding with Bogus - Apr. 15th, 2024**](https://www.youtube.com/watch?v=KoEOsfrRUqk&t=170s)
* [**Adventures in .NET: Building Bogus with Brian Chavez - Jan 5th, 2024**](https://www.youtube.com/watch?v=C1WwGKUY9K4)
* [**Microsoft Docs: Deploy Orleans to Azure App Service - May 5th, 2022**](https://docs.microsoft.com/en-us/dotnet/orleans/deployment/deploy-to-azure-app-service)
* [**Microsoft Docs: Modernize a WPF app tutorial - Aug. 2nd, 2019**](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/modernize-wpf-tutorial-1#configure-nuget-packages-and-dependencies)
* [**Microsoft Build 2018: Azure Tips and Tricks - May 8th, 2018**](https://www.youtube.com/watch?v=088e5IUqF6g&t=12m31s)
* **[NuGet Must Haves: Top 10 Unit Testing Libraries in 2017](http://nugetmusthaves.com/article/top-unit-testing-libraries)**
* **[.NET Rocks Podcast: #BetterKnowThatFramework - Mar. 16th 2017](https://twitter.com/bchavez/status/842479138850070528)**, **[Sep. 13th, 2018](https://twitter.com/bchavez/status/1040479669743628290)**, and **[May 7th, 2020](https://twitter.com/bchavez/status/1264047877245988864)**
* **[.NET Engineering Blog: NuGet Package of the week #1. - "This week in .NET - December 8th 2015"](https://blogs.msdn.microsoft.com/dotnet/2015/12/08/the-week-in-net-12082015/)**
##### Blog Posts
* [Nick Chapsas](https://twitter.com/nickchapsas) - [Generating realistic fake data in .NET using Bogus [YouTube]](https://www.youtube.com/watch?v=T9pwE1GAr_U)
* [Jack Histon](https://twitter.com/jackhiston) - [How to Create Bogus Data in C#](http://jackhiston.com/2017/10/1/how-to-create-bogus-data-in-c/)
* [Christos Matskas](https://twitter.com/christosmatskas) - [Creating .NET fakes using Bogus](https://cmatskas.com/creating-net-fakes-using-bogus-2/)
* [Jason Roberts](https://twitter.com/robertsjason) - [Lifelike Test Data Generation with Bogus](http://dontcodetired.com/blog/post/Lifelike-Test-Data-Generation-with-Bogus)
* Mark Timmings - [Auto generating test data with Bogus](http://putridparrot.com/blog/auto-generating-test-data-with-bogus/)
* [.NET Core Generating Test Data](https://coderulez.wordpress.com/2017/05/10/net-core-generating-test-data/)
* Steve Leigh - [Seedy Fake Users](http://stevesspace.com/2017/01/seedy-fake-users/)
* [Volkan Paksoy](https://twitter.com/volkan_paksoy) - [Generating Test Data with Bogus](https://volkanpaksoy.com/archive/2019/06/27/Generating-Test-Data-with-Bogus/)
* Alican Demirtas - [Bogus on F#](https://www.compositional-it.com/news-blog/bogus-on-f/)
* [Khalid Abuhakmeh](https://twitter.com/buhakmeh) - [Seed Entity Framework Core With Bogus](https://khalidabuhakmeh.com/seed-entity-framework-core-with-bogus)
* [Sander ten Brinke](https://twitter.com/sandertenbrinke) - [Taking Entity Framework Core data seeding to the next level with Bogus](https://stenbrinke.nl/blog/taking-ef-core-data-seeding-to-the-next-level-with-bogus/)
##### The Crypto Tip Jar!
Usage
-----
### The Great C# Example
```csharp
public enum Gender
{
Male,
Female
}
//Set the randomizer seed if you wish to generate repeatable data sets.
Randomizer.Seed = new Random(8675309);
var fruit = new[] { "apple", "banana", "orange", "strawberry", "kiwi" };
var orderIds = 0;
var testOrders = new Faker()
//Ensure all properties have rules. By default, StrictMode is false
//Set a global policy by using Faker.DefaultStrictMode
.StrictMode(true)
//OrderId is deterministic
.RuleFor(o => o.OrderId, f => orderIds++)
//Pick some fruit from a basket
.RuleFor(o => o.Item, f => f.PickRandom(fruit))
//A random quantity from 1 to 10
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 10))
//A nullable int? with 80% probability of being null.
//The .OrNull extension is in the Bogus.Extensions namespace.
.RuleFor(o => o.LotNumber, f => f.Random.Int(0, 100).OrNull(f, .8f));
var userIds = 0;
var testUsers = new Faker()
//Optional: Call for objects that have complex initialization
.CustomInstantiator(f => new User(userIds++, f.Random.Replace("###-##-####")))
//Use an enum outside scope.
.RuleFor(u => u.Gender, f => f.PickRandom())
//Basic rules using built-in generators
.RuleFor(u => u.FirstName, (f, u) => f.Name.FirstName(u.Gender))
.RuleFor(u => u.LastName, (f, u) => f.Name.LastName(u.Gender))
.RuleFor(u => u.Avatar, f => f.Internet.Avatar())
.RuleFor(u => u.UserName, (f, u) => f.Internet.UserName(u.FirstName, u.LastName))
.RuleFor(u => u.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName))
.RuleFor(u => u.SomethingUnique, f => $"Value {f.UniqueIndex}")
//Use a method outside scope.
.RuleFor(u => u.CartId, f => Guid.NewGuid())
//Compound property with context, use the first/last name properties
.RuleFor(u => u.FullName, (f, u) => u.FirstName + " " + u.LastName)
//And composability of a complex collection.
.RuleFor(u => u.Orders, f => testOrders.Generate(3).ToList())
//Optional: After all rules are applied finish with the following action
.FinishWith((f, u) =>
{
Console.WriteLine("User Created! Id={0}", u.Id);
});
var user = testUsers.Generate();
Console.WriteLine(user.DumpAsJson());
/* OUTPUT:
User Created! Id=0
*
{
"Id": 0,
"FirstName": "Audrey",
"LastName": "Spencer",
"FullName": "Audrey Spencer",
"UserName": "Audrey_Spencer72",
"Email": "Audrey82@gmail.com",
"Avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/itstotallyamy/128.jpg",
"CartId": "863f9462-5b88-471f-b833-991d68db8c93",
"SSN": "923-88-4231",
"Gender": 0,
"Orders": [
{
"OrderId": 0,
"Item": "orange",
"Quantity": 8
},
{
"OrderId": 1,
"Item": "banana",
"Quantity": 2
},
{
"OrderId": 2,
"Item": "kiwi",
"Quantity": 9
}
]
} */
```
#### More Examples!
| Language | Description |
|:---------:| ----------- |
| **C#** | [**Full working example of 'The Great C# Example'**](https://github.com/bchavez/Bogus/tree/master/Examples/GettingStarted) |
| **C#** | [**Using Bogus and EF Core to a seed database**](https://github.com/bchavez/Bogus/tree/master/Examples/EFCoreSeedDb) |
| **C#** | [**Extending Bogus with custom APIs and data**](https://github.com/bchavez/Bogus/tree/master/Examples/ExtendingBogus) |
| **F#** | [**Using Bogus with F#**](#the-fabulous-f-examples) |
| **VB.NET** | [**Using Bogus with VB.NET**](#the-very-basic-vbnet-example) |
### Locales
Since we're a port of **faker.js**, we support a whole bunch of different
locales. Here's an example in Korean:
```csharp
[Test]
public void With_Korean_Locale()
{
var lorem = new Bogus.DataSets.Lorem(locale: "ko");
Console.WriteLine(lorem.Sentence(5));
}
/* 국가는 무상으로 행위로 의무를 구성하지 신체의 처벌받지 예술가의 경우와 */
```
**Bogus** supports the following locales:
| Locale Code | Language | | Locale Code | Language |
|:------------:|:-----------------------:|-|:------------:|:------------------------:|
|`af_ZA` |Afrikaans ||`fr_CH` |French (Switzerland) |
|`ar` |Arabic ||`ge` |Georgian |
|`az` |Azerbaijani ||`hr` |Hrvatski |
|`cz` |Czech ||`id_ID` |Indonesia |
|`de` |German ||`it` |Italian |
|`de_AT` |German (Austria) ||`ja` |Japanese |
|`de_CH` |German (Switzerland) ||`ko` |Korean |
|`el` |Greek ||`lv` |Latvian |
|`en` |English ||`nb_NO` |Norwegian |
|`en_AU` |English (Australia) ||`ne` |Nepalese |
|`en_AU_ocker` |English (Australia Ocker) ||`nl` |Dutch |
|`en_BORK` |English (Bork) ||`nl_BE` |Dutch (Belgium) |
|`en_CA` |English (Canada) ||`pl` |Polish |
|`en_GB` |English (Great Britain) ||`pt_BR` |Portuguese (Brazil) |
|`en_IE` |English (Ireland) ||`pt_PT` |Portuguese (Portugal) |
|`en_IND` |English (India) ||`ro` |Romanian |
|`en_NG` |Nigeria (English) ||`ru` |Russian |
|`en_US` |English (United States) ||`sk` |Slovakian |
|`en_ZA` |English (South Africa) ||`sv` |Swedish |
|`es` |Spanish ||`tr` |Turkish |
|`es_MX` |Spanish (Mexico) ||`uk` |Ukrainian |
|`fa` |Farsi ||`vi` |Vietnamese |
|`fi` |Finnish ||`zh_CN` |Chinese |
|`fr` |French ||`zh_TW` |Chinese (Taiwan) |
|`fr_CA` |French (Canada) ||`zu_ZA` |Zulu (South Africa) |
***Note:*** Some locales may not have a complete data set. For example, [`zh_CN`](https://github.com/faker-js/faker.js/tree/master/lib/locales/zh_CN) does not have a `lorem` data set, but [`ko`](https://github.com/faker-js/faker.js/tree/master/lib/locales/ko) has a `lorem` data set. **Bogus** will default to `en` if a *locale-specific* data set is not found. To further illustrate the previous example, the missing `zh_CN:lorem` data set will default to the `en:lorem` data set.
If you'd like to help contribute new locales or update existing ones please see our
[Creating Locales](https://github.com/bchavez/Bogus/wiki/Creating-Locales) wiki page
for more info.
### Without Fluent Syntax
You can use **Bogus** without a fluent setup. The examples below highlight three alternative ways to use **Bogus** without a fluent syntax setup.
* Using the `Faker` facade.
* Using **DataSets** directly.
* Using `Faker` **inheritance**.
#### Using the `Faker` facade:
```csharp
public void Using_The_Faker_Facade()
{
var faker = new Faker("en");
var o = new Order()
{
OrderId = faker.Random.Number(1, 100),
Item = faker.Lorem.Sentence(),
Quantity = faker.Random.Number(1, 10)
};
o.Dump();
}
```
#### Using **DataSets** directly:
```csharp
public void Using_DataSets_Directly()
{
var random = new Bogus.Randomizer();
var lorem = new Bogus.DataSets.Lorem("en");
var o = new Order()
{
OrderId = random.Number(1, 100),
Item = lorem.Sentence(),
Quantity = random.Number(1, 10)
};
o.Dump();
}
```
#### Using `Faker` inheritance:
```csharp
public class OrderFaker : Faker {
public OrderFaker() {
RuleFor(o => o.OrderId, f => f.Random.Number(1, 100));
RuleFor(o => o.Item, f => f.Lorem.Sentence());
RuleFor(o => o.Quantity, f => f.Random.Number(1, 10));
}
}
public void Using_FakerT_Inheritance()
{
var orderFaker = new OrderFaker();
var o = orderFaker.Generate();
o.Dump();
}
```
In the examples above, all three alternative styles of using **Bogus** produce the same `Order` result:
```
{
"OrderId": 61,
"Item": "vel est ipsa",
"Quantity": 7
}
```
### Bogus API Support
* **`Address`**
* `ZipCode` - Get a zipcode.
* `City` - Get a city name.
* `StreetAddress` - Get a street address.
* `CityPrefix` - Get a city prefix.
* `CitySuffix` - Get a city suffix.
* `StreetName` - Get a street name.
* `BuildingNumber` - Get a building number.
* `StreetSuffix` - Get a street suffix.
* `SecondaryAddress` - Get a secondary address like 'Apt. 2' or 'Suite 321'.
* `County` - Get a county.
* `Country` - Get a country.
* `FullAddress` - Get a full address like Street, City, Country.
* `CountryCode` - Get a random ISO 3166-1 country code.
* `State` - Get a random state state.
* `StateAbbr` - Get a state abbreviation.
* `Latitude` - Get a Latitude.
* `Longitude` - Get a Longitude.
* `Direction` - Generates a cardinal or ordinal direction. IE: Northwest, South, SW, E.
* `CardinalDirection` - Generates a cardinal direction. IE: North, South, E, W.
* `OrdinalDirection` - Generates an ordinal direction. IE: Northwest, Southeast, SW, NE.
* **`Commerce`**
* `Department` - Get a random commerce department.
* `Price` - Get a random product price.
* `Categories` - Get random product categories.
* `ProductName` - Get a random product name.
* `Color` - Get a random color.
* `Product` - Get a random product.
* `ProductAdjective` - Random product adjective.
* `ProductMaterial` - Random product material.
* `Ean8` - Get a random EAN-8 barcode number.
* `Ean13` - Get a random EAN-13 barcode number.
* **`Company`**
* `CompanySuffix` - Get a company suffix. "Inc" and "LLC" etc.
* `CompanyName` - Get a company name.
* `CatchPhrase` - Get a company catch phrase.
* `Bs` - Get a company BS phrase.
* **`Database`**
* `Column` - Generates a column name.
* `Type` - Generates a column type.
* `Collation` - Generates a collation.
* `Engine` - Generates a storage engine.
* **`Date`**
* `Past` - Get a `DateTime` in the past between `refDate` and `yearsToGoBack`.
* `PastOffset` - Get a `DateTimeOffset` in the past between `refDate` and `yearsToGoBack`.
* `Soon` - Get a `DateTime` that will happen soon.
* `SoonOffset` - Get a `DateTimeOffset` that will happen soon.
* `Future` - Get a `DateTime` in the future between `refDate` and `yearsToGoForward`.
* `FutureOffset` - Get a `DateTimeOffset` in the future between `refDate` and `yearsToGoForward`.
* `Between` - Get a random `DateTime` between `start` and `end`.
* `BetweenOffset` - Get a random `DateTimeOffset` between `start` and `end`.
* `Recent` - Get a random `DateTime` within the last few days.
* `RecentOffset` - Get a random `DateTimeOffset` within the last few days.
* `Timespan` - Get a random `TimeSpan`.
* `Month` - Get a random month.
* `Weekday` - Get a random weekday.
* **`Finance`**
* `Account` - Get an account number. Default length is 8 digits.
* `AccountName` - Get an account name. Like "savings", "checking", "Home Loan" etc..
* `Amount` - Get a random amount. Default 0 - 1000.
* `TransactionType` - Get a transaction type: "deposit", "withdrawal", "payment", or "invoice".
* `Currency` - Get a random currency.
* `CreditCardNumber` - Generate a random credit card number with valid Luhn checksum.
* `CreditCardCvv` - Generate a credit card CVV.
* `BitcoinAddress` - Generates a random Bitcoin address.
* `EthereumAddress` - Generate a random Ethereum address.
* `RoutingNumber` - Generates an ABA routing number with valid check digit.
* `Bic` - Generates Bank Identifier Code (BIC) code.
* `Iban` - Generates an International Bank Account Number (IBAN).
* **`Hacker`**
* `Abbreviation` - Returns an abbreviation.
* `Adjective` - Returns a adjective.
* `Noun` - Returns a noun.
* `Verb` - Returns a verb.
* `IngVerb` - Returns a verb ending with -ing.
* `Phrase` - Returns a phrase.
* **`Images`**
* `DataUri` - Get a SVG data URI image with a specific width and height.
* `PicsumUrl` - Get an image from the https://picsum.photos service.
* `PlaceholderUrl` - Get an image from https://placeholder.com service.
* `LoremFlickrUrl` - Get an image from https://loremflickr.com service.
* **`Internet`**
* `Avatar` - Generates a legit Internet URL avatar from twitter accounts.
* `Email` - Generates an email address.
* `ExampleEmail` - Generates an example email with @example.com.
* `UserName` - Generates user names.
* `UserNameUnicode` - Generates a user name preserving Unicode characters.
* `DomainName` - Generates a random domain name.
* `DomainWord` - Generates a domain word used for domain names.
* `DomainSuffix` - Generates a domain name suffix like .com, .net, .org
* `Ip` - Gets a random IPv4 address string.
* `Port` - Generates a random port number.
* `IpAddress` - Gets a random IPv4 IPAddress type.
* `IpEndPoint` - Gets a random IPv4 IPEndPoint.
* `Ipv6` - Generates a random IPv6 address string.
* `Ipv6Address` - Generate a random IPv6 IPAddress type.
* `Ipv6EndPoint` - Gets a random IPv6 IPEndPoint.
* `UserAgent` - Generates a random user agent.
* `Mac` - Gets a random mac address.
* `Password` - Generates a random password.
* `Color` - Gets a random aesthetically pleasing color near the base RGB. See [here](http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette).
* `Protocol` - Returns a random protocol. HTTP or HTTPS.
* `Url` - Generates a random URL.
* `UrlWithPath` - Get an absolute URL with random path.
* `UrlRootedPath` - Get a rooted URL path like: /foo/bar. Optionally with file extension.
* **`Lorem`**
* `Word` - Get a random lorem word.
* `Words` - Get an array of random lorem words.
* `Letter` - Get a character letter.
* `Sentence` - Get a random sentence of specific number of words.
* `Sentences` - Get some sentences.
* `Paragraph` - Get a paragraph.
* `Paragraphs` - Get a specified number of paragraphs.
* `Text` - Get random text on a random lorem methods.
* `Lines` - Get lines of lorem.
* `Slug` - Slugify lorem words.
* **`Name`**
* `FirstName` - Get a first name. Getting a gender specific name is only supported on locales that support it.
* `LastName` - Get a last name. Getting a gender specific name is only supported on locales that support it.
* `FullName` - Get a full name, concatenation of calling FirstName and LastName.
* `Prefix` - Gets a random prefix for a name.
* `Suffix` - Gets a random suffix for a name.
* `FindName` - Gets a full name.
* `JobTitle` - Gets a random job title.
* `JobDescriptor` - Get a job description.
* `JobArea` - Get a job area expertise.
* `JobType` - Get a type of job.
* **`Phone`**
* `PhoneNumber` - Get a phone number.
* `PhoneNumberFormat` - Gets a phone number based on the locale's phone_number.formats[] array index.
* **`Rant`**
* `Review` - Generates a random user review.
* `Reviews` - Generate an array of random reviews.
* **`System`**
* `FileName` - Get a random file name.
* `DirectoryPath` - Get a random directory path (Unix).
* `FilePath` - Get a random file path (Unix).
* `CommonFileName` - Generates a random file name with a common file extension.
* `MimeType` - Get a random mime type.
* `CommonFileType` - Returns a commonly used file type.
* `CommonFileExt` - Returns a commonly used file extension.
* `FileType` - Returns any file type available as mime-type.
* `FileExt` - Gets a random extension for the given mime type.
* `Semver` - Get a random semver version string.
* `Version` - Get a random `Version`.
* `Exception` - Get a random `Exception` with a fake stack trace.
* `AndroidId` - Get a random GCM registration ID.
* `ApplePushToken` - Get a random Apple Push Token.
* `BlackBerryPin` - Get a random BlackBerry Device PIN.
* **`Vehicle`**
* `Vin` - Generate a vehicle identification number (VIN).
* `Manufacturer` - Get a vehicle manufacture name. IE: Toyota, Ford, Porsche.
* `Model` - Get a vehicle model. IE: Camry, Civic, Accord.
* `Type` - Get a vehicle type. IE: Minivan, SUV, Sedan.
* `Fuel` - Get a vehicle fuel type. IE: Electric, Gasoline, Diesel.
* **`Random`/`Randomizer`**
* `Number` - Get an int from 0 to max.
* `Digits` - Get a random sequence of digits.
* `Even` - Returns a random even number.
* `Odd` - Returns a random odd number.
* `Double` - Get a random double, between 0.0 and 1.0.
* `Decimal` - Get a random decimal, between 0.0 and 1.0.
* `Float` - Get a random float, between 0.0 and 1.0.
* `Byte` - Generate a random byte between 0 and 255.
* `Bytes` - Get a random sequence of bytes.
* `SByte` - Generate a random sbyte between -128 and 127.
* `Int` - Generate a random int between MinValue and MaxValue.
* `UInt` - Generate a random uint between MinValue and MaxValue.
* `ULong` - Generate a random ulong between MinValue and MaxValue.
* `Long` - Generate a random long between MinValue and MaxValue.
* `Short` - Generate a random short between MinValue and MaxValue.
* `UShort` - Generate a random ushort between MinValue and MaxValue.
* `Char` - Generate a random char between MinValue and MaxValue.
* `Chars` - Generate a random chars between MinValue and MaxValue.
* `String` - Get a string of characters of a specific length.
* `String2` - Get a string of characters with a specific length drawing characters from `chars`.
* `Hash` - Return a random hex hash. Default 40 characters, aka SHA-1.
* `Bool` - Get a random boolean.
* `ArrayElement` - Get a random array element.
* `ArrayElement` - Get a random array element.
* `ArrayElements` - Get a random subset of an array.
* `ListItem` - Get a random list item.
* `ListItems` - Get a random subset of a List.
* `CollectionItem` - Get a random collection item.
* `ReplaceNumbers` - Replaces symbols with numbers.
* `ReplaceSymbols` - Replaces each character instance in a string.
* `Replace` - Replaces symbols with numbers and letters. # = number, ? = letter, * = number or letter.
* `ClampString` - Clamps the length of a string between min and max characters.
* `Enum` - Picks a random Enum of T. Works only with Enums.
* `Shuffle` - Shuffles an IEnumerable source.
* `Word` - Returns a single word or phrase in English.
* `Words` - Gets some random words and phrases in English.
* `WordsArray` - Get a range of words in an array (English).
* `Guid` - Get a random GUID.
* `Uuid` - Get a random GUID. Alias for Randomizer.Guid().
* `RandomLocale` - Returns a random locale.
* `AlphaNumeric` - Returns a random set of alpha numeric characters 0-9, a-z.
* `Hexadecimal` - Generates a random hexadecimal string.
* `WeightedRandom` - Returns a selection of T[] based on a weighted distribution of probability.
#### API Extension Methods
* **`using Bogus.Extensions.Belgium;`**
* `Bogus.Person.NationalNumber()` - Rijksregisternummer / Numéro Nationale
* **`using Bogus.Extensions.Brazil;`**
* `Bogus.Person.Cpf()` - Cadastro de Pessoas Físicas
* `Bogus.DataSets.Company.Cnpj()` - Cadastro Nacional da Pessoa Jurídica
* **`using Bogus.Extensions.Canada;`**
* `Bogus.Person.Sin()` - Social Insurance Number for Canada
* **`using Bogus.Extensions.Denmark;`**
* `Bogus.Person.Cpr()` - Danish Personal Identification number
* **`using Bogus.Extensions.Finland;`**
* `Bogus.Person.Henkilotunnus()` - Finnish Henkilötunnus
* **`using Bogus.Extensions.Italy;`**
* `Bogus.Person.CodiceFiscale()` - Codice Fiscale
* `Bogus.DataSets.Finance.CodiceFiscale()` - Codice Fiscale
* **`using Bogus.Extensions.Norway;`**
* `Bogus.Person.Fodselsnummer()` - Norwegian national identity number
* **`using Bogus.Extensions.Poland;`**
* `Bogus.Person.Pesel()` - Number of Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
* `Bogus.DataSets.Company.Nip()` - Numer identyfikacji podatkowej (NIP)
* `Bogus.DataSets.Company.Regon()` - Number of Rejestr Gospodarki Narodowej (REGON)
* **`using Bogus.Extensions.Portugal;`**
* `Bogus.Person.Nif()` - Número de Identificação Fiscal (NIF)
* `Bogus.DataSets.Company.Nipc()` - Número de Identificação de Pessoa Colectiva (NIPC)
* **`using Bogus.Extensions.Romania;`**
* `Bogus.Person.Cnp()` - Romanian Personal Identification number (CNP)
* **`using Bogus.Extensions.Sweden;`**
* `Bogus.Person.Personnummer()` - Swedish national identity number
* `Bogus.Person.Samordningsnummer()` - Swedish coordination number
* **`using Bogus.Extensions.UnitedKingdom;`**
* `Bogus.DataSets.Vehicle.GbRegistrationPlate()` - GB Vehicle Registration Plate
* `Bogus.DataSets.Finance.SortCode()` - Banking Sort Code
* `Bogus.DataSets.Finance.Nino()` - National Insurance Number
* `Bogus.DataSets.Finance.VatNumber()` - Generates a UK compatible VAT registration number
* `Bogus.DataSets.Address.CountryOfUnitedKingdom()` - Country of the United Kingdom
* **`using Bogus.Extensions.UnitedStates;`**
* `Bogus.Person.Ssn()` - Social Security Number
* `Bogus.DataSets.Company.Ein()` - Employer Identification Number
* **`using Bogus.Distributions.Gaussian;`**
* `Randomizer.GaussianInt()` - Generate an `int` based on a specific normal distribution.
* `Randomizer.GaussianFloat()` - Generate a `float` based on a specific normal distribution.
* `Randomizer.GaussianDouble()` - Generate a `double` based on a specific normal distribution.
* `Randomizer.GaussianDecimal()` - Generate a `decimal` based on a specific normal distribution.
#### Amazing Community Extensions
* [**AutoBogus**](https://github.com/nickdodd79/AutoBogus) ([`NuGet Package`](https://www.nuget.org/packages?q=AutoBogus)) by [@nickdodd79](https://github.com/nickdodd79/) - Extends **Bogus** by adding automatic `.RuleFor()` creation and population capabilities.
* [**NaughtyStrings.Bogus**](https://github.com/SimonCropp/NaughtyStrings) ([`NuGet Package`](https://www.nuget.org/packages/NaughtyStrings.Bogus/)) by [@SimonCropp](https://github.com/SimonCropp) - Extends **Bogus** with list of naughty strings which have a high probability of causing issues when used as user-input data. Examples:
* `.SQLInjection()` - Strings which can cause a SQL injection if inputs are not sanitized.
* `.ScriptInjection()` - Strings which attempt to invoke a benign script injection; shows vulnerability to XSS.
* `.iOSVulnerabilities()` - Strings which crashed iMessage in various versions of iOS.
* `.KnownCVEsandVulnerabilities()` - Strings that test for known vulnerabilities.
* `.ServerCodeInjection()` - Strings which can cause user to run code on server as a privileged user.
* and more!
* [**WaffleGenerator.Bogus**](https://github.com/SimonCropp/WaffleGenerator) ([`NuGet Package`](https://www.nuget.org/packages/WaffleGenerator.Bogus/)) by [@SimonCropp](https://github.com/SimonCropp) - The Waffle Generator produces of text which, on first glance, looks like real, ponderous, prose; replete with clichés.
* [**NodaTime.Bogus**](https://github.com/SimonCropp/NodaTime.Bogus) ([`NuGet Package`](https://www.nuget.org/packages/NodaTime.Bogus/)) by [@SimonCropp](https://github.com/SimonCropp) - Adds support for [NodaTime](https://nodatime.org/) to **Bogus**.
* [**CountryData.Bogus**](https://github.com/SimonCropp/CountryData) ([`NuGet Package`](https://www.nuget.org/packages/CountryData.Bogus/)) by [@SimonCropp](https://github.com/SimonCropp) - Wrapper around [GeoNames Data](https://www.geonames.org/). Examples:
* `.Country().Name()` - Random country name.
* `.Country().CurrencyCode()` - Random currency code.
* `.Australia().Capital()` - Country capital.
* `.Country().Iceland().PostCode()` - Random country post code.
* [**AustralianElectorates.Bogus**](https://github.com/pmcau/AustralianElectorates) ([`NuGet Package`](https://www.nuget.org/packages/AustralianElectorates.Bogus/)) by [@SimonCropp](https://github.com/SimonCropp) - Wrapper around Australian Electoral Commission (AEC) data (https://www.aec.gov.au/). Examples:
* `.AustralianElectorates().Electorate()` - Random electorate.
* `.AustralianElectorates().Name()` - Random electorate name.
* `.AustralianElectorates().CurrentMember()` - Random current electorate member for parliament.
* `.AustralianElectorates().CurrentMemberName()` - Random name of current a electorate member for parliament.
* `.AustralianElectorates().Member()` - Random electorate member for parliament.
* `.AustralianElectorates().MemberName()` - Random name of a electorate member for parliament.
## Bogus Premium Extensions!
**Bogus Premium** [[**Purchase Now!**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium)] by [@bchavez](https://github.com/bchavez) You can help support the **Bogus** open source project by purchasing a [**Bogus Premium**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) license! With an active premium license you'll be supporting this cool open-source project. You'll also gain new superpowers that extended **Bogus** with new features and exclusive data sets! Check 'em out below!
* **Premium:** [**Bogus.Tools.Analyzer**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) ([NuGet Package](https://www.nuget.org/packages/Bogus.Tools.Analyzer/)) - Save time using this handy Roslyn analyzer to generate and detect missing `.RuleFor()` rules at development & compile time! This tool is included with the [**Bogus Premium**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) license!
* **Premium:** [**Bogus.Locations**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) ([NuGet Package](https://www.nuget.org/packages/Bogus.Locations/)) - A dataset that contains real geographical information for places and things. Create fake GPS points and paths. Helpful for creating geodesic data for location-based aware apps.
* **`Location`**
* `Altitude` - Generate a random altitude, in meters. Default max height is 8848m (Mount Everest). Heights are always positive.
* `AreaCircle` - Get a latitude and longitude within a specific radius in meters.
* `Depth` - Generate a random depth, in meters. Default max depth is -10994m (Mariana Trench). Depths are always negative.
* `Geohash` - Generates a random Geohash. [See](https://en.wikipedia.org/wiki/Geohash).
* **Premium:** [**Bogus.Healthcare**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) ([NuGet Package](https://www.nuget.org/packages/Bogus.Healthcare/)) - A data set for the Healthcare industry. Generate fake medical records, injuries, diagnosis, drugs, dosages, human anatomy, and ICD-9 medical codes. Especially helpful in HIPAA regulated environments!
* **`Drugs`**
* `Administration` - Get how a drug should be administered. IE: oral, nasal, injection.
* `Dosage` - Get a drug dosage with MG units
* `DosageAmount` - Get a drug dosage.
* `DosageForm` - Get the form of a drug. IE: tablet, capsule, gel.
* `Ingredient` - Get a drug ingredient. IE: folic acid, magnesium hydroxide, ibuprofen.
* `Vitamin` - Get a random vitamin.
* **`Human`**
* `BloodType` - Get a random blood type. Ex: A+, OB
* `BodyPartExternal` - Get an external body part name. IE: Head, Arm, Leg.
* `BodyPartInternal` - Get an internal body part name. IE: Bladder, Lung, Heart.
* `BodyRegion` - Get a human body region. IE: Head and Neck, Thorax.
* `BodySystem` - Get a human body system. IE: Digestive, Nervous, Circulatory.
* `Diagnosis` - Shortcut to Icd9.DiagnosisLongDescription".
* `InfectiousDisease` - Get an infectious disease. IE: Chickenpox, Polio, Zika Fever.
* `Pain` - Get a human pain. Ex: Chest pain, Headache, Toothache.
* `Plasma` - Get a random plasma type. Ex: O, A, B, AB
* `Procedure` - Shortcut to Icd9.ProcedureLongDescription.
* **`Icd9`**
* `DiagnosisCode` - Get a ICD9 diagnosis code.
* `DiagnosisEntry` - Get a medical diagnosis.
* `DiagnosisLongDescription` - Get a medical diagnosis description. IE: Meningitis due to coxsackie virus.
* `DiagnosisShortDescription` - Get a short description of a medical diagnosis.
* `ProcedureCode` - Get a ICD9 procedure code.
* `ProcedureEntry` - Get a medical procedure.
* `ProcedureLongDescription` - Get a medical procedure description.
* `ProcedureShortDescription` - Get a short description of a medical procedure.
* **`Icd10`**
* `DiagnosisCode` - Get a ICD10 diagnosis code.
* `DiagnosisEntry` - Get a medical diagnosis.
* `DiagnosisLongDescription` - Get a medical diagnosis description. IE: Meningitis due to coxsackie virus.
* `DiagnosisShortDescription` - Get a short description of a medical diagnosis.
* `ProcedureCode` - Get a ICD10 procedure code.
* `ProcedureEntry` - Get a medical procedure.
* `ProcedureLongDescription` - Get a medical procedure description.
* `ProcedureShortDescription` - Get a short description of a medical procedure.
* **`Medical`**
* `Hospital` - Get a random hospital.
* `HospitalCity` - Get a hospital city.
* `HospitalName` - Get a random hospital name. IE: UCLA Medical Center
* `HospitalState` - Get a hospital state.
* `HospitalStreetAddress` - Get a hospital street address.
* `HospitalZipCode` - Get a hospital ZipCode.
* `Phrase` - Get a random medical phrase.
* `Word` - Get a medical word.
* **Premium:** [**Bogus.Hollywood**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) ([NuGet Package](https://www.nuget.org/packages/Bogus.Hollywood/))- A dataset for the Entertainment industry.
* **`Movies`**
* `ActorName` - Get a famous actor. IE: Keanu Reeves, Liam Neeson, and Natalie Portman.
* `MovieCollection` - Get a random movie collection. IE: Star Wars Collection, Indiana Jones Collection.
* `MovieOverview` - Get a random movie overview
* `MovieReleaseDate` - Get a random movie release date.
* `MovieTagline` - Get a random movie tagline.
* `MovieTitle` - Get a random movie title
* `Production` - Get a production company.
* **`Tv`**
* `ActorName` - Get a famous actor. IE: Keanu Reeves, Liam Neeson, and Natalie Portman.
* `Network` - Get a random TV network. IE: BBC, ABC, NBC, FOX.
* `Production` - Get a production company
* `Series` - Get a name of a TV series. IE: Rick and Morty, Silicon Valley, The Walking Dead
* **Premium:** [**Bogus.Text**](https://github.com/bchavez/Bogus/wiki/Bogus-Premium) ([NuGet Package](https://www.nuget.org/packages/Bogus.Text/)) - A dataset that contains historical texts in the public domain. Create fake sentences from famous speeches, classic books, and law
* **`Literature`**
* `CommonSense` - Text from "Common Sense, by Thomas Paine (1776)"
* `JfkSpeech` - Text from "JFK's Inaugural Address"
* `Knowledge` - Text from "A Treatise Concerning the Principles of Human knowledge, by George Berkeley (1710)"
---
### Helper Methods
The features shown below come standard with the [**Bogus**](https://www.nuget.org/packages/Bogus/) NuGet package.
#### Person
If you want to generate a `Person` with context relevant properties like
an email that looks like it belongs to someone with the same first/last name,
create a person!
```csharp
[Test]
public void Create_Context_Related_Person()
{
var person = new Bogus.Person();
person.Dump();
}
/* OUTPUT:
{
"FirstName": "Lee",
"LastName": "Brown",
"UserName": "Lee_Brown3",
"Avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ccinojasso1/128.jpg",
"Email": "Lee_Brown369@yahoo.com",
"DateOfBirth": "1984-01-16T21:31:27.87666",
"Address": {
"Street": "2552 Bernard Rapid",
"Suite": "Suite 199",
"City": "New Haskell side",
"ZipCode": "78425-0411",
"Geo": {
"Lat": -35.8154,
"Lng": -140.2044
}
},
"Phone": "1-500-790-8836 x5069",
"Website": "javier.biz",
"Company": {
"Name": "Kuphal and Sons",
"CatchPhrase": "Organic even-keeled monitoring",
"Bs": "open-source brand e-business"
}
} */
```
#### Replace
Replace a formatted string with random numbers `#`, letters `?`, or `*` random number or letter:
```csharp
[Test]
public void Create_an_SSN()
{
var ssn = new Bogus.Randomizer().Replace("###-##-####");
ssn.Dump();
var code = new Randomizer().Replace("##? ??? ####");
code.Dump();
var serial = new Randomizer().Replace("**-****");
serial.Dump();
}
/* OUTPUT:
"618-19-3064"
"39E SPC 0790"
"L3-J9N5"
*/
```
#### Parse Handlebars
You can also parse strings in the following format:
```csharp
[Test]
public void Handlebar()
{
var faker = new Faker();
var randomName = faker.Parse("{{name.lastName}}, {{name.firstName}} {{name.suffix}}");
randomName.Dump();
}
/* OUTPUT:
"Roob, Michale PhD"
*/
```
The name of a dataset is determined using `DataCategory` attribute or class name otherwise. (i.e `PhoneNumber` dataset in handlebars expression should be named as `phone_number`)
You can pass parameters to methods using braces:
```csharp
[Test]
public void HandlebarWithParameters()
{
var faker = new Faker();
var randomName = faker.Parse("{{name.firstname(Female)}}, {{name.firstname(Male)}}");
randomName.Dump();
}
/* OUTPUT:
"Lindsay, Jonathan"
*/
```
#### Implicit and Explicit Type Conversion
You can also use implicit type conversion to make your code look cleaner without having to explicitly call `Faker.Generate()`.
```csharp
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => f.IndexVariable++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Quantity, f => f.Random.Number(1,3));
Order testOrder1 = orderFaker;
Order testOrder2 = orderFaker;
testOrder1.Dump();
testOrder2.Dump();
/* OUTPUT:
{
"OrderId": 0,
"Item": "Computer",
"Quantity": 2
}
{
"OrderId": 1,
"Item": "Tuna",
"Quantity": 3
}
*/
//Explicit works too!
var anotherOrder = (Order)orderFaker;
```
#### Bulk Rules
Sometimes writing `.RuleFor(x => x.Prop, ...)` can get repetitive, use the `.Rules((f, t) => {...})` shortcut to specify rules in bulk as shown below:
```csharp
public void create_rules_for_an_object_the_easy_way()
{
var faker = new Faker()
.StrictMode(false)
.Rules((f, o) =>
{
o.Quantity = f.Random.Number(1, 4);
o.Item = f.Commerce.Product();
o.OrderId = 25;
});
Order o = faker.Generate();
}
```
***Note***: When using the bulk `.Rules(...)` action, `StrictMode` cannot be set to `true` since individual properties of type `T` cannot be independently checked to ensure each property has a rule.
### Using `Enumerable.Range()` and LINQ
The `Enumerable.Range()` and LINQ are a great supplement when creating data with **Bogus**. Here's how to generate a simple list of email addresses:
```csharp
var faker = new Faker("en");
var emailList = Enumerable.Range(1, 5)
.Select(_ => faker.Internet.Email())
.ToList();
//OUTPUT:
Gustave83@hotmail.com
Evie33@gmail.com
Abby_Wilkinson@yahoo.com
Cecilia.Hahn@yahoo.com
Jasen.Waelchi85@gmail.com
```
Advanced Topics, Guidance, and Best Practices
---------------------------------------------
### Determinism
Determinism is a first class concept in **Bogus**. **Bogus** goes to great lengths so developers can generate the same sequence of data over multiple program executions. **Bogus** has two strategies of setting up deterministic behavior:
1. **Global Seed** determinism through the `Randomizer.Seed` **global static** property.
***Pros:*** Easy to get deterministic data setup quickly.
***Cons:*** Code changes can impact other data values. Not so good for unit tests.
2. **Local Seed** determinism through instance **properties** and **methods**. Specifically,
* The `Faker.UseSeed(int)` **method**.
* The `.Random` **property** on the `Faker` facade and **DataSets**.
***Pros:*** Code changes can be isolated with minimal impact on determinism. Good for unit tests.
***Cons:*** Requires some forethought in design.
When **Local Seed** determinism is used to set a seed value, the **global static** source of randomness is ignored. This has some interesting implications as described below.
#### Using Global Seed determinism
The easiest way to get deterministic data values over multiple executions of a program is to set the `Randomizer.Seed` property as demonstrated below:
```csharp
Randomizer.Seed = new Random(1338);
var orderIds = 0;
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => orderIds++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 5));
orderFaker.Generate(5).Dump();
```
| OrderId | Item | Quantity |
|:---------:|:--------:|:----------:|
| 0 | Fish | 3 |
| 1 | Chair | 1 |
| 2 | Gloves | 5 |
| 3 | Shirt | 4 |
| 4 | Hat | 4 |
Re-running the code above with `1338` as a global static seed value will produce the same table of data over and over again.
Next, add a new `Description` property to the `Order` class along with a new `.RuleFor(o => o.Description, ..)` rule and see the data changes:
```csharp
Randomizer.Seed = new Random(1338);
var orderIds = 0;
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => orderIds++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Description, f => f.Commerce.ProductAdjective()) //New Rule
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 5));
orderFaker.Generate(5).Dump();
```
| OrderId | Item | Description | Quantity |
|---------|----------|-------------|----------|
| 0 | Fish | Fantastic | :triangular_flag_on_post: 1 |
| 1 | :triangular_flag_on_post: Keyboard | :triangular_flag_on_post: Gorgeous | :triangular_flag_on_post: 5 |
| 2 | :triangular_flag_on_post: Shirt | :triangular_flag_on_post: Handcrafted | :triangular_flag_on_post: 3 |
| 3 | :triangular_flag_on_post: Tuna | :triangular_flag_on_post: Small | :triangular_flag_on_post: 1 |
| 4 | :triangular_flag_on_post: Table | :triangular_flag_on_post: Awesome | :triangular_flag_on_post: 3 |
A couple of observations:
* `Order 0: Item` value `Fish` remained the same.
* `Order 0: Quantity` changed from `3` to `1`.
* `Order 1: Item` has changed from a `Chair` to a `Keyboard`.
In fact, every data value with a :triangular_flag_on_post: icon has changed. This is due to the newly added property which has the effect of shifting the entire global static pseudo-random sequence off by +1. This rippling effect can be a problem if unit tests are expecting data values to remain the same. The following section below shows how we can improve the situation.
#### Using Local Seed determinism
Making use of the `Faker.UseSeed(int)` method can help limit the impact of POCO schema changes on deterministic data values that span across an entire run. Consider the following code that uses a seed value for each instance of a POCO object:
```csharp
var orderIds = 0;
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => orderIds++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 5));
Order SeededOrder(int seed){
return orderFaker.UseSeed(seed).Generate();
}
var orders = Enumerable.Range(1, 5)
.Select(SeededOrder)
.ToList();
orders.Dump();
```
| OrderId | Item | Quantity |
|:---------:|:--------:|:----------:|
| 0 | Bike | 1 |
| 1 | Cheese | 3 |
| 2 | Gloves | 4 |
| 3 | Bacon | 5 |
| 4 | Pants | 2 |
Next, adding the `Description` property to the `Order` class and examining the output:
```csharp
var orderIds = 0;
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => orderIds++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Description, f => f.Commerce.ProductAdjective()) //New Rule
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 5));
Order SeededOrder(int seed){
return orderFaker.UseSeed(seed).Generate();
}
var orders = Enumerable.Range(1,5)
.Select(SeededOrder)
.ToList();
orders.Dump();
```
| OrderId | Item | Description | Quantity |
|---------|--------|-------------|----------|
| 0 | Bike | Ergonomic | :triangular_flag_on_post: 3 |
| 1 | Cheese | Fantastic | :triangular_flag_on_post: 1 |
| 2 | Gloves | Handcrafted | :triangular_flag_on_post: 5 |
| 3 | Bacon | Tasty | :triangular_flag_on_post: 3 |
| 4 | Pants | Gorgeous | :triangular_flag_on_post: 2 |
Progress! This time only the `Quantity` data values with the :triangular_flag_on_post: icon have changed. The `Item` column remained the same before and after the new addition of the `Description` property.
We can further prevent the `Quantity` data values from changing by moving the `RuleFor(o => o.Description,...)` rule line to the end of the `Faker` declaration as shown below:
```csharp
var orderIds = 0;
var orderFaker = new Faker()
.RuleFor(o => o.OrderId, f => orderIds++)
.RuleFor(o => o.Item, f => f.Commerce.Product())
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 5))
.RuleFor(o => o.Description, f => f.Commerce.ProductAdjective()); //New Rule
Order MakeOrder(int seed){
return orderFaker.UseSeed(seed).Generate();
}
var orders = Enumerable.Range(1,5)
.Select(MakeOrder)
.ToList();
orders.Dump();
````
| OrderId | Item | Quantity | Description |
|:---------:|:--------:|:----------:|:-------------:|
| 0 | Bike | 1 | Practical |
| 1 | Cheese | 3 | Rustic |
| 2 | Gloves | 4 | Refined |
| 3 | Bacon | 5 | Awesome |
| 4 | Pants | 2 | Gorgeous |
Much success! :100: :tada: The `Item` and `Quantity` values remain unchanged! The new `Description` property is added to the POCO object without any impact to other deterministic data values.
As a best practice, to achieve maximum deterministic behavior and unit test robustness with **Bogus**:
* :heavy_check_mark: Add new `RuleFor` rules last in `Faker` declarations.
* :heavy_check_mark: Avoid changing existing rules.
* :heavy_check_mark: Always use `Faker.UseSeed(int)` to avoid using the global static seed as a source for randomness.
* :heavy_check_mark: When possible assert that a value exists, not the literal value itself. In other words,
```csharp
// Don't do this:
firstOrder.Item.Should().Be("Bike");
// Instead, do this:
firstOrder.Item.Should().NotBeNullOrWhiteSpace();
```
-------
The `Faker` facade and individual **DataSets** can also be prepared to use **local seeds** as well. The following shows how to set up the `Faker` facade and **DataSets** to use local seeds:
```csharp
var faker = new Faker("en")
{
Random = new Randomizer(1338)
};
var lorem = new Bogus.DataSets.Lorem("en"){
Random = new Randomizer(1338)
};
faker.Lorem.Word().Dump();
lorem.Word().Dump();
//OUTPUT:
minus
minus
```
The `.Random` property can be set multiple times without any ill effects.
#### Versioning can effect determinism
Updating to new versions of **Bogus** on NuGet can effect determinism too. For example, when **Bogus** updates locales from **faker.js** or issues bug fixes, sometimes deterministic sequences can change. Changes to deterministic outputs are usually highlighted in the [release notes](https://github.com/bchavez/Bogus/blob/master/HISTORY.md). Changes to deterministic outputs is also considered a breaking change. **Bogus** generally follows semantic versioning rules. For example:
| Version | Description |
|---------|-------------|
| **Bogus** v25.0.**1** | Initial version. |
| **Bogus** v25.0.**2** | No change to deterministic outputs or breaking changes. Possible bug fixes & improvements. |
| **Bogus** v**26**.0.1 | Deterministic outputs may have changed or may include other breaking changes. |
As a general rule of thumb,
* :heavy_check_mark: For maximum stability for unit tests, stay within the same major versions of **Bogus**.
* :heavy_check_mark: For those wanting to stay up to date, assert that a value exists, not a literal value itself. In other words,
```csharp
// Don't do this:
firstOrder.Item.Should().Be("Bike");
// Instead, do this:
firstOrder.Item.Should().NotBeNullOrWhiteSpace();
```
#### Deterministic Dates and Times
**Bogus** can generate deterministic dates and times. However, generating deterministic dates and times requires the following:
1. Setting up a [seed value](#determinism).
1. Setting up a time reference for your Faker object instance.
The following code shows how to setup deterministic dates and times:
```csharp
// Faker[T]: Set a local seed and a time reference
var fakerT = new Faker()
.UseSeed(1338)
.UseDateTimeReference(DateTime.Parse("1/1/1980"))
.RuleFor(o => o.SoonValue, f => f.Date.Soon())
.RuleFor(o => o.RecentValue, f => f.Date.Recent());
fakerT.Generate().Dump();
// { "SoonValue": "1980-01-01T17:33:05",
// "RecentValue": "1979-12-31T14:07:31" }
// Faker: Set a local seed and a time reference
var faker = new Faker
{
Random = new Randomizer(1338),
DateTimeReference = DateTime.Parse("1/1/1980")
};
faker.Date.Soon(); // "1980-01-01T17:33:05"
faker.Date.Recent(); // "1979-12-31T14:07:31"
```
With a time reference set and a [seed](#determinism), dates and times should be deterministic across multiple runs of a program.
F# and VB.NET Examples
----------------------
#### The Fabulous F# Examples
* Using the `Faker` facade with immutable **F#** record types:
```fsharp
type Customer = { FirstName : string
LastName : string
Age : int
Title : string }
//The faker facade
let f = Faker();
let generator() =
{ FirstName = f.Name.FirstName()
LastName = f.Name.LastName()
Age = f.Random.Number(18,60)
Title = f.Name.JobTitle() }
generator() |> Dump |> ignore
(* OUTPUT:
FirstName = "Russell"
LastName = "Nader"
Age = 34
Title = "Senior Web Officer"
*)
```
* Using the `Faker` class with immutable **F#** record types:
```fsharp
type Customer = { FirstName : string
LastName : string
Age : int
Title : string }
let customerFaker =
Bogus
.Faker()
.CustomInstantiator(fun f ->
{ FirstName = f.Name.FirstName()
LastName = f.Name.LastName()
Age = f.Random.Number(18,60)
Title = f.Name.JobTitle() })
customerFaker.Generate() |> Dump |> ignore
(* OUTPUT:
FirstName = "Sasha"
LastName = "Roberts"
Age = 20;
Title = "Internal Security Specialist"
*)
```
* Using the `Faker` class with mutable classes in **F#**:
```fsharp
open Bogus
type Customer() =
member val FirstName = "" with get, set
member val LastName = "" with get, set
member val Age = 0 with get, set
member val Title = "" with get, set
let faker =
Faker()
//Make a rule for each property
.RuleFor( (fun c -> c.FirstName), fun (f:Faker) -> f.Name.FirstName() )
.RuleFor( (fun c -> c.LastName), fun (f:Faker) -> f.Name.LastName() )
//Or, alternatively, in bulk with .Rules()
.Rules( fun f c ->
c.Age <- f.Random.Int(18,35)
c.Title <- f.Name.JobTitle() )
faker.Generate() |> Dump |> ignore
(* OUTPUT:
FirstName: Jarrell
LastName: Tremblay
Age: 32
Title: Senior Web Designer
*)
```
#### The Very Basic VB.NET Example
```vb
Imports Bogus
Public Class Customer
Public Property FirstName() As String
Public Property LastName() As String
Public Property Age() As Integer
Public Property Title() As String
End Class
Sub Main
Dim faker As New Faker(Of Customer)
'-- Make a rule for each property
faker.RuleFor( Function(c) c.FirstName, Function(f) f.Name.FirstName) _
.RuleFor( Function(c) c.LastName, Function(f) f.Name.LastName) _
_
.Rules( Sub(f, c) '-- Or, alternatively, in bulk with .Rules()
c.Age = f.Random.Int(18,35)
c.Title = f.Name.JobTitle()
End Sub )
faker.Generate.Dump
End Sub
' OUTPUT:
' FirstName: Jeremie
' LastName: Mills
' Age: 32
' Title: Quality Supervisor
```
Building From Source
--------
The following section is only useful for people looking to contribute to **Bogus** or make custom modifications to **Bogus**. This section includes information about building **Bogus** from source code and is not required to operate or run **Bogus** in **.NET** applications.
The minimum requirements to build **Bogus** from source code are as follows:
* **Windows 11** or later.
* [**Git for Windows**](https://git-scm.com/downloads) `v2.39.2` or later.
* [**.NET Framework**](https://dotnet.microsoft.com/download/dotnet-framework) `v4.7.2`.
* **.NET SDK**
* LTS [`SDK v10.0.100`](https://dotnet.microsoft.com/download/dotnet/10.0)
* LTS [`SDK v8.0.100`](https://dotnet.microsoft.com/download/dotnet/8.0)
* LTS [`SDK v6.0.417`](https://dotnet.microsoft.com/download/dotnet/6.0)
* Optional:
* Visual Studio 2026 or later - IDE with C# 14 support.
#### Build Instructions
* Download the source code.
* Open command prompt and run `build.cmd`:
* `build restore` - restores all project references.
* `build compile` - the main dotnet build task.
* `build clean` - cleans sources and files.
* `build zip` - creates a nice zip file with debug and release binaries.
* `build pack` - builds **NuGet** packages.
* `build test` - runs all unit tests.
The following folders will be created depending on the build task executed:
* `\__compile` - binary output folder for the compiler.
* `\__package` - output folder for zip and **NuGet** packages.
* `\__test` - test results folder.
#### Build Environment Variables
* `set FORCE_VERSION=1.2.3`
If `FORCE_VERSION` environment variable is set with a semantic version number (eg: `x.y.z`), the build tasks will use the `FORCE_VERSION` to produce builds with the exact version number. Useful for testing out-of-band custom builds. However, it is not possible to reproduce exact binary equivalents of released **NuGet** packages because packages release on **NuGet** contain assemblies that are digitally signed with assembly signing enabled. The public does not have access to the signing key.
#### Rebundling Locales
Re-bundling the latest locale data from **faker.js** requires the following software installed:
* [**Volta 1.1.1**](https://volta.sh) or later:
* Installs [**NodeJS**](https://nodejs.org/) `v12.18.1` or higher.
* [**gulp**](https://gulpjs.com/) `v4` or higher.
Steps to re-bundle locale data from **faker.js**:
1. `git clone https://github.com/bchavez/Bogus.git`
1. `cd Bogus`
1. `git submodule init`
1. `git submodule update`
1. Ensure **NodeJS** and `gulp` are properly installed.
1. `cd Source\Builder`
1. `npm install` to install required dev dependencies.
1. `npx gulp importLocales` to regenerate locales in `Source\Bogus\data`.
1. Finally, run `build.cmd`.
### License
* [MIT License](https://github.com/bchavez/Bogus/blob/master/LICENSE)
Sponsors
---------
A special thank you to the companies that have sponsored and helped with the development of **Bogus** in big ways.
| Date | | Company |
|------|---|-------|
| **2024 - October** | | [**Amazon AWS .NET FOSS Fund**](https://github.com/aws/dotnet-foss?tab=readme-ov-file#funding-recipients)
| **2022 - June** | | [**GitHub**](https://github.blog/open-source/maintainers/thank-you-to-our-maintainers) |
Contributors
---------
Created by [Brian Chavez](https://bchavez.bitarmory.com).
A big thanks to GitHub and all contributors:
* [Anton Georgiev](https://github.com/antongeorgiev)
* [Martijn Laarman](https://github.com/Mpdreamz)
* [Anrijs Vitolins](https://github.com/salixzs)
* [Pi Lanningham](https://github.com/quantumplation)
* [JvanderStad](https://github.com/JvanderStad)
* [Giuseppe Dimauro](https://github.com/gdimauro)
================================================
FILE: Source/.editorconfig
================================================
[*]
end_of_line=crlf
trim_trailing_whitespace=false
insert_final_newline=false
indent_style=space
indent_size=3
[{*.yml,*.yaml}]
indent_style=space
indent_size=3
================================================
FILE: Source/Benchmark/BenchGenerate.cs
================================================
using System.Linq;
using BenchmarkDotNet.Attributes;
using Bogus;
namespace Benchmark
{
[MarkdownExporter, MemoryDiagnoser]
public class BenchGenerate
{
public class Project
{
public long Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
private static Faker FakerDefault { get; set; }
private static Faker FakerCustom { get; set; }
private static Faker FakerWithRules { get; set; }
private static Faker FakerWithRulesComplex { get; set; }
[GlobalSetup]
public void Setup()
{
FakerDefault = new Faker().UseSeed(1337);
FakerCustom = new Faker()
.CustomInstantiator(f=> new Project())
.UseSeed(1337);
FakerWithRules = new Faker()
.CustomInstantiator(f=> new Project())
.RuleFor(p=>p.Id, f => f.IndexGlobal)
.UseSeed(1337);
FakerWithRulesComplex = new Faker()
.CustomInstantiator(f=> new Project())
.RuleFor(p=>p.Id, f => f.IndexGlobal)
.RuleFor(p => p.Name, f => f.Person.Company.Name + f.UniqueIndex.ToString())
.RuleFor(p => p.Description, f => f.Lorem.Paragraphs(3))
.UseSeed(1337);
}
// [Benchmark]
public void Generate_Default()
{
var projects = FakerDefault.Generate(10_000).ToList();
}
// [Benchmark]
public void Generate_CustomInstantiator()
{
var projects = FakerDefault.Generate(10_000).ToList();
}
[Benchmark]
public void Generate_WithRules()
{
var projects = FakerWithRules.Generate(10_000).ToList();
}
//[Benchmark]
public void Generate_WithRulesComplex()
{
var projects = FakerWithRulesComplex.Generate(10_000).ToList();
}
// [Benchmark]
public void Constructor()
{
var projects = Enumerable.Range(0, 10_000).Select(i => new Project {Id = i}).ToList();
}
}
}
================================================
FILE: Source/Benchmark/BenchRandomSubset.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Bogus;
namespace Benchmark
{
[RPlotExporter]
public class BenchRandomSubset
{
private Randomizer r;
private List items;
[Params(2, 10, 100, 500, 1000, 1999)]
public int Selections { get; set; }
[GlobalSetup]
public void Setup()
{
r = new Randomizer();
items = Enumerable.Range(1, 2000).ToList();
}
[Benchmark]
public void PickRandom()
{
PickRandom(items, this.Selections).ToList();
}
[Benchmark]
public void ShuffleTake()
{
r.Shuffle(items).Take(this.Selections).ToList();
}
///
/// Helper to pick random subset of elements out of the list.
///
/// amount of elements to pick of the list.
/// if amountToPick is lower than zero.
public IEnumerable PickRandom(IEnumerable items, int amountToPick)
{
if (amountToPick < 0)
{
throw new ArgumentOutOfRangeException($"{nameof(amountToPick)} needs to be a positive integer.");
}
var size = items.Count();
if (amountToPick > size)
{
throw new ArgumentOutOfRangeException($"{nameof(amountToPick)} is greater than the number of items.");
}
foreach (var item in items)
{
if (amountToPick <= 0)
{
yield break;
}
if (r.Int(1, size) <= amountToPick)
{
amountToPick--;
yield return item;
}
size--;
}
}
}
}
================================================
FILE: Source/Benchmark/BenchSsn.cs
================================================
using BenchmarkDotNet.Attributes;
using Bogus;
namespace Benchmark
{
[RPlotExporter]
public class BenchSsn
{
private Randomizer r;
[GlobalSetup]
public void Setup()
{
r = new Randomizer(1337);
}
[Benchmark]
public void SsnAlgo1()
{
var a = r.Int(1, 898);
if (a == 666) a++;
var b = r.Int(1, 99);
var c = r.Int(1, 9999);
var result = $"{a:000}-{b:00}-{c:0000}";
}
[Benchmark]
public void SsnAlgo2()
{
var a = r.Int(1, 898);
if (a == 666) a++;
var b = r.Int(1, 99);
var c = r.Int(1, 9999);
var result = $"{a:000}-{b:00}-{c:0000}";
}
[Benchmark]
public void SsnAlgo3()
{
var x = r.Int();
// right shift all bits except fir the first 10 bits = 2^10 = 1024.
var a = (x >> (32 - 10)) % 898;
if (a is 0 or 666) a++;
// use the first 7 bits = 2^7 = 128
var b = (x & 0x7F);
if (b == 0) b++;
// last 2^14 = 16384, for last 4 digits of SSN
var c = (x >> 7) & 0x3FFF;
if (c == 0) c++;
var result = $"{a:000}-{b:00}-{c:0000}";
}
}
}
================================================
FILE: Source/Benchmark/BenchStringFill.cs
================================================
using System.Text;
using BenchmarkDotNet.Attributes;
using Bogus;
namespace Benchmark
{
[RPlotExporter]
public class BenchStringFill
{
[Params(2, 10, 100, 500, 1000, 5000, 20000)]
public int TargetLength { get; set; }
//[Params("abcd","abcdefghijklmnopqrstuvwxyz",
// "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")]
public string Pool { get; set; } = "abcdefghijklmnopqrstuvwxyz";
[GlobalSetup]
public void Setup()
{
this.r = new Randomizer();
}
private Randomizer r;
private string result;
[Benchmark]
public void FillWithStringBuilder()
{
var sb = new StringBuilder(this.TargetLength);
for( int i = 0; i < this.TargetLength; i++ )
{
var idx = r.Number(0, this.Pool.Length - 1);
sb.Append(this.Pool[idx]);
}
this.result = sb.ToString();
}
[Benchmark]
public void FillWithFixedCharArray()
{
var target = new char[this.TargetLength];
for (int i = 0; i < this.TargetLength; i++)
{
var idx = r.Number(0, this.Pool.Length - 1);
target[i] = this.Pool[idx];
}
this.result = new string(target);
}
}
}
================================================
FILE: Source/Benchmark/Benchmark.csproj
================================================
netstandard2.0AnyCPUportabletruetruetrueRelease
================================================
FILE: Source/Benchmark/PR300_BenchDecimal.cs
================================================
using System;
using System.Threading;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Bogus;
namespace Benchmark
{
[SimpleJob(RuntimeMoniker.NetCoreApp31), SimpleJob(RuntimeMoniker.Net471)]
[MarkdownExporter, MemoryDiagnoser, RPlotExporter]
public class PR300_BenchDecimal
{
private CustomRandomizer r;
[GlobalSetup]
public void Setup()
{
r = new CustomRandomizer();
}
[Benchmark]
public decimal OldMethod()
{
return r.Decimal();
}
[Benchmark]
public decimal JDGMethod()
{
return r.DecimalJDG();
}
[Benchmark]
public decimal JDGMethodNoAlloc()
{
return r.DecimalJDGNoAlloc();
}
[Benchmark]
public decimal JDGMethodNoAllocMult()
{
return r.DecimalJDGNoAllocMult();
}
}
public class CustomRandomizer : Randomizer
{
internal static Lazy