aliostad / randomgen Goto Github PK
View Code? Open in Web Editor NEWA simple random generation framework for .NET Core and 4.52+
License: MIT License
A simple random generation framework for .NET Core and 4.52+
License: MIT License
Let's replace Json.NET
with System.Text.Json
, one less dependency to worry about.
Also, I'm running into versioning clash in one of my test project that uses RandomGen (that depends on Json.NET 11) and CosmosDB (that depends on Json.NET 10) - having to maintain binding redirections.
I don't believe we need a config option to specify the json serializer used as it's only needed to load resource files.
I'm happy to implement the change.
We use this library to generate random names in the demo environment of our product. A customer was recently offended by the name "Rivka Shyrock", because of Rivka being a Jewish first name, and Shyrock being very close to Shylock, which is a character in Shakespeare that is offensive to Jews.
I suggest replacing "Shyrock" with some other last name.
I understand it's hard to foresee possible combinations of names that could be considered offensive in various cultures. We have worked around this in our code, but want to make you aware of the potential issue.
I'm considering implementing a fluent API,
Right now we have a collection of RandomXXX()
methods and they are not grouped in any way. As more features are added it may be difficult to find a certain generator. Also, since all those methods begin with Random
they don't play nice with intellisense.
I would like to suggest we group related methods using fluent API (examples):
Gen.Random().Dates()
Gen.Random().Doubles()
Gen.Random().Text(length: 50)
Gen.Random().Text().Short()
Gen.Random().Text().Long()
Gen.Random().Text().ReallyLong()
Gen.Random().Names().Female()
Gen.Random().Names().Male()
Gen.Random().Names().Surnames()
Gen.Random().Names().FullNames()
The methods above will return current Func<>
generators.
I'm thinking about adding another set of methods for 'updating' single values:
Gen.Change().Double(74.5).By(10).Percent()
Gen.Change().Double(74.5).By(10).Absolute()
The former methods would return a random double in range [67.05-81.95], the latter [64.5-84.5].
That can be applied to dates as well:
Gen.Change().Date(xxx).By(21).Days()
Gen.Change().Date(xxx).By(5).Weeks()
Gen.Change().Date(xxx).By(2).Months()
Sign the assembly before posting to NuGet, please.
With * .snk.
Hi great framework ๐ how can I extend this to other values,
There is a lack of tools like this.
It would be nice to reflect of a DB table (or EF entity) and populate the records based on the column types/names
Hi Ali!
Is there a way to set the seed value for the underlying Random?
This is particularly helpful for consistent results when replaying from an event log :)
cheers,
Harry
Each of the following examples throws the exception:
Specified argument was out of the range of valid values.
Parameter name: min >= max
var @int = RandomGen.Gen.Random.Numbers.Integers(1, 1)(); var @decimal = RandomGen.Gen.Random.Numbers.Decimals(1, 1)(); var @double = RandomGen.Gen.Random.Numbers.Doubles(1, 1)(); var @long = RandomGen.Gen.Random.Numbers.Longs(1, 1)(); var @uint = RandomGen.Gen.Random.Numbers.UnsignedIntegers(1, 1)();
The System.Numerics.BigInteger
class is used to generate arbitrarily large integers.
Extending the text generator to just generate numbers but return a string would add this quite easily. Using BigInteger.Parse(string)
If @jkonecki are OK, I will add this one too.
Each of the following examples throws the exception:
Specified argument was out of the range of valid values.
Parameter name: min >= max
var _int = RandomGen.Gen.Random.Numbers.Integers(1, 1)();
var _decimal = RandomGen.Gen.Random.Numbers.Decimals(1, 1)();
var _double = RandomGen.Gen.Random.Numbers.Doubles(1, 1)();
var _long = RandomGen.Gen.Random.Numbers.Longs(1, 1)();
var _uint = RandomGen.Gen.Random.Numbers.UnsignedIntegers(1, 1)();
Hi
I get domain names with arabic or hindu characters or something.
I use these email addresses to create fake users with a third party system, which appaently checks email addresses for vailidity.
Could you add some sanity checking to e-mails? I'm not talking about checking that domain names exist or anything like that, but at least generate valid characters.
Hi!
I get errors when I call the Gen.Random.Countries()() method in the Swarm container.
$ locale
LANG=C.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
Error Message:
System.Globalization.CultureNotFoundException : Culture is not supported. (Parameter 'culture') 4096 (0x1000) is an invalid culture identifier.
Stack Trace:
at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)
at System.Globalization.RegionInfo..ctor(Int32 culture)
at RandomGen.RandomLink.<>c.<Countries>b__22_0(CultureInfo culture)
at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.DistinctIterator`1.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at RandomGen.RandomLink.Items[T](IEnumerable`1 items, IEnumerable`1 weights)
at RandomGen.RandomLink.Countries()
The build on appveyor is failing
https://ci.appveyor.com/project
Curently RandomGen supports creation of generators (Func<T>
) that can be used to obtain a series of random items.
I found that in most cases I require a single random item at a time.
The solution is to either store the generators (Func<T>
) and reuse them between calls or to evaluate the function instantly (Gen.Random.Numbers.Integers()()
) which doesn't look nice in code ()()
.
What I would like to be able to do is write just:
var number = Gen.Random.Numbers.Integers();
.
I would like to propose that we create an additional set of methods that would compliment the existing ones and allow for single items to be generated:
Func<int> Gen.Random.Numbers.Integers()
int Gen.Random.Number.Integer()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.