FakerLib.Net 1.0.0

dotnet add package FakerLib.Net --version 1.0.0
                    
NuGet\Install-Package FakerLib.Net -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FakerLib.Net" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FakerLib.Net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FakerLib.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FakerLib.Net --version 1.0.0
                    
#r "nuget: FakerLib.Net, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FakerLib.Net@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FakerLib.Net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FakerLib.Net&version=1.0.0
                    
Install as a Cake Tool

FakerLib.Net

This is the official repository of the FakerLib.Net dummy data generator library for .NET

What is FakerLib.Net?

FakerLib.Net is a simple .NET Core package that can be used to create dummy (fake) list of collections. That is, populate any type of collections (List) (Enumerables) with random data of different sorts : Name, Cities, Phonenumbers, Countries, ZipCodes, UUIDs, Addresses, IPAddresses, URLs, Websites, EmailAddresses, ImageURLs etc. It could be used to populate DB's, collections and so on during development and testing.

Where can I get it?

First, install NuGet. Then, install FakerLib.Net from the package manager console:

PM> Install-Package FakerLib.Net

Or from the .NET CLI as:

dotnet add package FakerLib.Net

How do I get started?

First, configure FakerLib.Net FakerFactory to let it know what properties of a type (e.g class) do want to generate fake/dummy for by annotating each property of choice by a FakeAttribute like below: For instance, for a model class of Person, you would configure like below:

public class Person
{
        [Fake(FakerType.Name)]
        public string Name { get; set; }
        [Fake(FakerType.City)]
        public string City { get; set; }
        [Fake(FakerType.Phone)]
        public string Phone { get; set; }
        public string HouseAddress { get; set; } = string.Empty;
}

All FakerTypes that you can use

public enum FakerType
    {
        Name = 0,
        Sentence = 1,
        ImageUrl = 2,
        Phone = 3,
        City = 4,
        Country = 5,
        TextParagraph = 6,
        Website = 7,
        IpAddress = 8,
        Guid = 9,
        GuidString = 10,
        DateTime = 11,
        Numeric = 12,
        Address = 13,
        EmailAddress = 14,
        ZipCode = 15,
        Url = 16
    }

Then anywhere in your application code where you need a list of type(Person) filled with dummy data, use below.

var fakerFactory = new FakerFactory();
var dummyListOfPersons = fakerFactory.Setup<Person>(typeof(Person), 5) //meaning to generate 5 items of this type(Person) of dummy data.

OR you can use Dependency Injection by registering FakerFactory in your startup.cs DI container like below

//For .NET 6 and above
builder.Services.AddFakerFactory();

//For .NET 5 and below
services.AddFakerFactory();

//then you can inject typeof(IFakerFactory) into any class's constructor and make use of it. 
private readonly IFakerFactory _fakerFactory;
public PersonService(IFakerFactory fakerFactory)
{
_fakerFactory = fakerFactory;
}

//Then make use of it somewhere inside this service class like below.
var dummyListOfPersons = _fakerFactory.Setup<Person>(typeof(Person), 5) //meaning to generate 5 items of this type(Person) of dummy data.

Do you have an issue?

If you're facing some problems using the package, file an issue above.

License, etc.

FakerLib.Net is Copyright © 2022 Faith Olusegun and other contributors under the MIT license.

And this project was first inspired in 2019 by the Faker Library in PHP Laravel. Not until now was it made real for C# .NET.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 977 10/27/2022