From 2dda28495285733aa0bcd37d4577c779f452523d Mon Sep 17 00:00:00 2001 From: s2quake Date: Sun, 2 Nov 2025 12:44:22 +0900 Subject: [PATCH 1/5] docs(random): translate and complete XML docs for RandomUtility, Nullable, and Tuple - Add/translate English XML documentation for public APIs - Ensure and tags are complete and XML is valid - No functional changes --- src/JSSoft.Randora/RandomUtility.Nullable.cs | 874 +++++++++++++++++++ src/JSSoft.Randora/RandomUtility.Tuple.cs | 406 +++++++++ src/JSSoft.Randora/RandomUtility.cs | 708 +++++++++++++++ 3 files changed, 1988 insertions(+) diff --git a/src/JSSoft.Randora/RandomUtility.Nullable.cs b/src/JSSoft.Randora/RandomUtility.Nullable.cs index 1fbcf7a..e53fecd 100644 --- a/src/JSSoft.Randora/RandomUtility.Nullable.cs +++ b/src/JSSoft.Randora/RandomUtility.Nullable.cs @@ -7,310 +7,1184 @@ namespace JSSoft.Randora; public static partial class RandomUtility { + /// + /// Generates a random nullable sbyte value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static sbyte? NullableSByte() => Nullable(SByte); + /// + /// Generates a random nullable sbyte value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static sbyte? NullableSByte(Random random) => Nullable(random, SByte); + /// + /// Generates a random nullable byte value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static byte? NullableByte() => Nullable(Byte); + /// + /// Generates a random nullable byte value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static byte? NullableByte(Random random) => Nullable(random, Byte); + /// + /// Generates a random nullable 16-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static short? NullableInt16() => Nullable(Int16); + /// + /// Generates a random nullable 16-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static short? NullableInt16(Random random) => Nullable(random, Int16); + /// + /// Generates a random nullable unsigned 16-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static ushort? NullableUInt16() => Nullable(UInt16); + /// + /// Generates a random nullable unsigned 16-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static ushort? NullableUInt16(Random random) => Nullable(random, UInt16); + /// + /// Generates a random nullable 32-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static int? NullableInt32() => Nullable(Int32); + /// + /// Generates a random nullable 32-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static int? NullableInt32(Random random) => Nullable(random, Int32); + /// + /// Generates a random nullable unsigned 32-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static uint? NullableUInt32() => Nullable(UInt32); + /// + /// Generates a random nullable unsigned 32-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static uint? NullableUInt32(Random random) => Nullable(random, UInt32); + /// + /// Generates a random nullable 64-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static long? NullableInt64() => Nullable(Int64); + /// + /// Generates a random nullable 64-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static long? NullableInt64(Random random) => Nullable(random, Int64); + /// + /// Generates a random nullable unsigned 64-bit integer using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static ulong? NullableUInt64() => Nullable(UInt64); + /// + /// Generates a random nullable unsigned 64-bit integer using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static ulong? NullableUInt64(Random random) => Nullable(random, UInt64); + /// + /// Generates a random nullable single-precision floating-point value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static float? NullableSingle() => Nullable(Single); + /// + /// Generates a random nullable single-precision floating-point value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static float? NullableSingle(Random random) => Nullable(random, Single); + /// + /// Generates a random nullable double-precision floating-point value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static double? NullableDouble() => Nullable(Double); + /// + /// Generates a random nullable double-precision floating-point value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static double? NullableDouble(Random random) => Nullable(random, Double); + /// + /// Generates a random nullable decimal value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static decimal? NullableDecimal() => Nullable(Decimal); + /// + /// Generates a random nullable decimal value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static decimal? NullableDecimal(Random random) => Nullable(random, Decimal); + /// + /// Generates a random nullable BigInteger value using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static BigInteger? NullableBigInteger() => Nullable(BigInteger); + /// + /// Generates a random nullable BigInteger value using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static BigInteger? NullableBigInteger(Random random) => Nullable(random, BigInteger); + /// + /// Generates a random nullable string using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static string? NullableString() => NullableObject(String); + /// + /// Generates a random nullable string using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static string? NullableString(Random random) => NullableObject(random, String); + /// + /// Generates a random nullable character using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static char? NullableChar() => Nullable(Char); + /// + /// Generates a random nullable character using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static char? NullableChar(Random random) => Nullable(random, Char); + /// + /// Generates a random nullable DateTimeOffset using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static DateTimeOffset? NullableDateTimeOffset() => Nullable(DateTimeOffset); + /// + /// Generates a random nullable DateTimeOffset using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static DateTimeOffset? NullableDateTimeOffset(Random random) => Nullable(random, DateTimeOffset); + /// + /// Generates a random nullable TimeSpan using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static TimeSpan? NullableTimeSpan() => Nullable(TimeSpan); + /// + /// Generates a random nullable TimeSpan using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static TimeSpan? NullableTimeSpan(Random random) => Nullable(random, TimeSpan); + /// + /// Generates a random nullable boolean using the shared random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// public static bool? NullableBoolean() => Nullable(Boolean); + /// + /// Generates a random nullable boolean using the specified random source. + /// Approximately 66% of calls return a non-null value; otherwise, null. + /// + /// The random source to use. public static bool? NullableBoolean(Random random) => Nullable(random, Boolean); + /// + /// Generates a nullable array using the shared random source. Returns null or an array whose elements are produced by . + /// + /// The element type. + /// The element generator. + /// Null or a generated array. public static T[]? NullableArray(Func generator) => NullableObject(() => Array(generator)); + /// + /// Generates a nullable array using the specified random source. Returns null or an array whose elements are produced by with . + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated array. public static T[]? NullableArray(Random random, Func generator) => NullableObject(random, random => Array(random, generator)); + /// + /// Generates a nullable List using the shared random source. Returns null or a list whose elements are produced by . + /// + /// The element type. + /// The element generator. + /// Null or a generated list. public static List? NullableList(Func generator) => NullableObject(() => List(generator)); + /// + /// Generates a nullable List using the shared random source with a fixed length. Returns null or a list of the specified . + /// + /// The element type. + /// The element generator. + /// The desired list length. + /// Null or a generated list. public static List? NullableList(Func generator, int length) => NullableObject(() => List(generator, length)); + /// + /// Generates a nullable List using the specified random source. Returns null or a list whose elements are produced by with . + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated list. public static List? NullableList(Random random, Func generator) => NullableObject(random, random => List(random, generator)); + /// + /// Generates a nullable List using the specified random source and fixed length. Returns null or a list of the specified . + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired list length. + /// Null or a generated list. public static List? NullableList(Random random, Func generator, int length) => NullableObject(random, random => List(random, generator, length)); + /// + /// Generates a nullable HashSet using the shared random source. + /// + /// The element type. + /// The element generator. + /// Null or a generated set. public static HashSet? NullableHashSet(Func generator) => NullableObject(() => HashSet(generator)); + /// + /// Generates a nullable HashSet using the shared random source with a fixed length. + /// + /// The element type. + /// The element generator. + /// The desired item count upper bound. + /// Null or a generated set. public static HashSet? NullableHashSet(Func generator, int length) => NullableObject(() => HashSet(generator, length)); + /// + /// Generates a nullable HashSet using the specified random source. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated set. public static HashSet? NullableHashSet(Random random, Func generator) => NullableObject(random, random => HashSet(random, generator)); + /// + /// Generates a nullable HashSet using the specified random source with a fixed length. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired item count upper bound. + /// Null or a generated set. public static HashSet? NullableHashSet(Random random, Func generator, int length) => NullableObject(random, random => HashSet(random, generator, length)); + /// + /// Generates a nullable Dictionary using the shared random source. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// Null or a generated dictionary. public static Dictionary? NullableDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(() => Dictionary(keyGenerator, valueGenerator)); + /// + /// Generates a nullable Dictionary using the shared random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// The desired number of entries. + /// Null or a generated dictionary. public static Dictionary? NullableDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(() => Dictionary(keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable Dictionary using the specified random source. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// Null or a generated dictionary. public static Dictionary? NullableDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(random, random => Dictionary(random, keyGenerator, valueGenerator)); + /// + /// Generates a nullable Dictionary using the specified random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// The desired number of entries. + /// Null or a generated dictionary. public static Dictionary? NullableDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(random, random => Dictionary(random, keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable ImmutableArray using the shared random source. + /// + /// The element type. + /// The element generator. + /// Null or a generated immutable array. public static ImmutableArray? NullableImmutableArray(Func generator) => Nullable(() => ImmutableArray(generator)); + /// + /// Generates a nullable ImmutableArray using the shared random source with a fixed length. + /// + /// The element type. + /// The element generator. + /// The desired item count. + /// Null or a generated immutable array. public static ImmutableArray? NullableImmutableArray(Func generator, int length) => Nullable(() => ImmutableArray(generator, length)); + /// + /// Generates a nullable ImmutableArray using the specified random source. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated immutable array. public static ImmutableArray? NullableImmutableArray(Random random, Func generator) => Nullable(random, random => ImmutableArray(random, generator)); + /// + /// Generates a nullable ImmutableArray using the specified random source with a fixed length. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired item count. + /// Null or a generated immutable array. public static ImmutableArray? NullableImmutableArray(Random random, Func generator, int length) => Nullable(random, random => ImmutableArray(random, generator, length)); + /// + /// Generates a nullable ImmutableList using the shared random source. + /// + /// The element type. + /// The element generator. + /// Null or a generated immutable list. public static ImmutableList? NullableImmutableList(Func generator) => NullableObject(() => ImmutableList(generator)); + /// + /// Generates a nullable ImmutableList using the shared random source with a fixed length. + /// + /// The element type. + /// The element generator. + /// The desired item count. + /// Null or a generated immutable list. public static ImmutableList? NullableImmutableList(Func generator, int length) => NullableObject(() => ImmutableList(generator, length)); + /// + /// Generates a nullable ImmutableList using the specified random source. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated immutable list. public static ImmutableList? NullableImmutableList(Random random, Func generator) => NullableObject(random, random => ImmutableList(random, generator)); + /// + /// Generates a nullable ImmutableList using the specified random source with a fixed length. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired item count. + /// Null or a generated immutable list. public static ImmutableList? NullableImmutableList(Random random, Func generator, int length) => NullableObject(random, random => ImmutableList(random, generator, length)); + /// + /// Generates a nullable ImmutableHashSet using the shared random source. + /// + /// The element type. + /// The element generator. + /// Null or a generated immutable set. public static ImmutableHashSet? NullableImmutableHashSet(Func generator) => NullableObject(() => ImmutableHashSet(generator)); + /// + /// Generates a nullable ImmutableHashSet using the shared random source with a fixed length. + /// + /// The element type. + /// The element generator. + /// The desired item count upper bound. + /// Null or a generated immutable set. public static ImmutableHashSet? NullableImmutableHashSet(Func generator, int length) => NullableObject(() => ImmutableHashSet(generator, length)); + /// + /// Generates a nullable ImmutableHashSet using the specified random source. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated immutable set. public static ImmutableHashSet? NullableImmutableHashSet(Random random, Func generator) => NullableObject(random, random => ImmutableHashSet(random, generator)); + /// + /// Generates a nullable ImmutableHashSet using the specified random source with a fixed length. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired item count upper bound. + /// Null or a generated immutable set. public static ImmutableHashSet? NullableImmutableHashSet(Random random, Func generator, int length) => NullableObject(random, random => ImmutableHashSet(random, generator, length)); + /// + /// Generates a nullable ImmutableSortedSet using the shared random source. + /// + /// The element type. + /// The element generator. + /// Null or a generated immutable sorted set. public static ImmutableSortedSet? NullableImmutableSortedSet(Func generator) => NullableObject(() => ImmutableSortedSet(generator)); + /// + /// Generates a nullable ImmutableSortedSet using the shared random source with a fixed length. + /// + /// The element type. + /// The element generator. + /// The desired item count upper bound. + /// Null or a generated immutable sorted set. public static ImmutableSortedSet? NullableImmutableSortedSet(Func generator, int length) => NullableObject(() => ImmutableSortedSet(generator, length)); + /// + /// Generates a nullable ImmutableSortedSet using the specified random source. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// Null or a generated immutable sorted set. public static ImmutableSortedSet? NullableImmutableSortedSet(Random random, Func generator) => NullableObject(random, random => ImmutableSortedSet(random, generator)); + /// + /// Generates a nullable ImmutableSortedSet using the specified random source with a fixed length. + /// + /// The element type. + /// The random source to use. + /// The element generator that accepts a random source. + /// The desired item count upper bound. + /// Null or a generated immutable sorted set. public static ImmutableSortedSet? NullableImmutableSortedSet(Random random, Func generator, int length) => NullableObject(random, random => ImmutableSortedSet(random, generator, length)); + /// + /// Generates a nullable ImmutableDictionary using the shared random source. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// Null or a generated immutable dictionary. public static ImmutableDictionary? NullableImmutableDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(() => ImmutableDictionary(keyGenerator, valueGenerator)); + /// + /// Generates a nullable ImmutableDictionary using the shared random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// The desired number of entries. + /// Null or a generated immutable dictionary. public static ImmutableDictionary? NullableImmutableDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(() => ImmutableDictionary(keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable ImmutableDictionary using the specified random source. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// Null or a generated immutable dictionary. public static ImmutableDictionary? NullableImmutableDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(random, random => ImmutableDictionary(random, keyGenerator, valueGenerator)); + /// + /// Generates a nullable ImmutableDictionary using the specified random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// The desired number of entries. + /// Null or a generated immutable dictionary. public static ImmutableDictionary? NullableImmutableDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(random, random => ImmutableDictionary(random, keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable ImmutableSortedDictionary using the shared random source. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// Null or a generated immutable sorted dictionary. public static ImmutableSortedDictionary? NullableImmutableSortedDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(() => ImmutableSortedDictionary(keyGenerator, valueGenerator)); + /// + /// Generates a nullable ImmutableSortedDictionary using the shared random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The key generator. + /// The value generator. + /// The desired number of entries. + /// Null or a generated immutable sorted dictionary. public static ImmutableSortedDictionary? NullableImmutableSortedDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(() => ImmutableSortedDictionary(keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable ImmutableSortedDictionary using the specified random source. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// Null or a generated immutable sorted dictionary. public static ImmutableSortedDictionary? NullableImmutableSortedDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => NullableObject(random, random => ImmutableSortedDictionary(random, keyGenerator, valueGenerator)); + /// + /// Generates a nullable ImmutableSortedDictionary using the specified random source with a fixed length. + /// + /// The key type. + /// The value type. + /// The random source to use. + /// The key generator that accepts a random source. + /// The value generator that accepts a random source. + /// The desired number of entries. + /// Null or a generated immutable sorted dictionary. public static ImmutableSortedDictionary? NullableImmutableSortedDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => NullableObject(random, random => ImmutableSortedDictionary(random, keyGenerator, valueGenerator, length)); + /// + /// Generates a nullable Tuple of two elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The first element generator. + /// The second element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2) => NullableObject(() => Tuple(generator1, generator2)); + /// + /// Generates a nullable Tuple of two elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2) => NullableObject(random, random => Tuple(random, generator1, generator2)); + /// + /// Generates a nullable Tuple of three elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3) => NullableObject(() => Tuple(generator1, generator2, generator3)); + /// + /// Generates a nullable Tuple of three elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3) => NullableObject(random, random => Tuple(random, generator1, generator2, generator3)); + /// + /// Generates a nullable Tuple of four elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3, Func generator4) => NullableObject(() => Tuple(generator1, generator2, generator3, generator4)); + /// + /// Generates a nullable Tuple of four elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4) => NullableObject(random, random => Tuple(random, generator1, generator2, generator3, generator4)); + /// + /// Generates a nullable Tuple of five elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => NullableObject(() => Tuple(generator1, generator2, generator3, generator4, generator5)); + /// + /// Generates a nullable Tuple of five elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => NullableObject(random, random => Tuple(random, generator1, generator2, generator3, generator4, generator5)); + /// + /// Generates a nullable Tuple of six elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => NullableObject(() => Tuple(generator1, generator2, generator3, generator4, generator5, generator6)); + /// + /// Generates a nullable Tuple of six elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => NullableObject(random, random => Tuple(random, generator1, generator2, generator3, generator4, generator5, generator6)); + /// + /// Generates a nullable Tuple of seven elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => NullableObject(() => Tuple(generator1, generator2, generator3, generator4, generator5, generator6, generator7)); + /// + /// Generates a nullable Tuple of seven elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => NullableObject(random, random => Tuple(random, generator1, generator2, generator3, generator4, generator5, generator6, generator7)); + /// + /// Generates a nullable Tuple of eight elements (the eighth is TRest) using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The type of the eighth element (TRest). + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// The eighth element generator. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : notnull => NullableObject(() => Tuple(generator1, generator2, generator3, generator4, generator5, generator6, generator7, generator8)); + /// + /// Generates a nullable Tuple of eight elements (the eighth is TRest) using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The type of the eighth element (TRest). + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// The eighth element generator that accepts a random source. + /// Null or a generated Tuple. public static Tuple? NullableTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : notnull => NullableObject(random, random => Tuple(random, generator1, generator2, generator3, generator4, generator5, generator6, generator7, generator8)); + /// + /// Generates a nullable value tuple of two elements using element generators with the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The first element generator. + /// The second element generator. + /// Null or a generated value tuple. public static (T1, T2)? NullableValueTuple(Func generator1, Func generator2) => Nullable(() => ValueTuple(generator1, generator2)); + /// + /// Generates a nullable value tuple of two elements using element generators with the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2)? NullableValueTuple(Random random, Func generator1, Func generator2) => Nullable(random, random => ValueTuple(random, generator1, generator2)); + /// + /// Generates a nullable value tuple of three elements using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// Null or a generated value tuple. public static (T1, T2, T3)? NullableValueTuple(Func generator1, Func generator2, Func generator3) => Nullable(() => ValueTuple(generator1, generator2, generator3)); + /// + /// Generates a nullable value tuple of three elements using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3) => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3)); + /// + /// Generates a nullable value tuple of four elements using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// Null or a generated value tuple. public static (T1, T2, T3, T4)? NullableValueTuple(Func generator1, Func generator2, Func generator3, Func generator4) => Nullable(() => ValueTuple(generator1, generator2, generator3, generator4)); + /// + /// Generates a nullable value tuple of four elements using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3, T4)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4) => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3, generator4)); + /// + /// Generates a nullable value tuple of five elements using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5)? NullableValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => Nullable(() => ValueTuple(generator1, generator2, generator3, generator4, generator5)); + /// + /// Generates a nullable value tuple of five elements using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3, generator4, generator5)); + /// + /// Generates a nullable value tuple of six elements using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6)? NullableValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => Nullable(() => ValueTuple(generator1, generator2, generator3, generator4, generator5, generator6)); + /// + /// Generates a nullable value tuple of six elements using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3, generator4, generator5, generator6)); + /// + /// Generates a nullable value tuple of seven elements using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6, T7)? NullableValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => Nullable(() => ValueTuple(generator1, generator2, generator3, generator4, generator5, generator6, generator7)); + /// + /// Generates a nullable value tuple of seven elements using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6, T7)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3, generator4, generator5, generator6, generator7)); + /// + /// Generates a nullable value tuple of eight elements (the eighth is TRest) using the shared random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The type of the eighth element (TRest). + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// The eighth element generator. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6, T7, TRest)? NullableValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : struct => Nullable(() => ValueTuple(generator1, generator2, generator3, generator4, generator5, generator6, generator7, generator8)); + /// + /// Generates a nullable value tuple of eight elements (the eighth is TRest) using the specified random source. + /// + /// The type of the first element. + /// The type of the second element. + /// The type of the third element. + /// The type of the fourth element. + /// The type of the fifth element. + /// The type of the sixth element. + /// The type of the seventh element. + /// The type of the eighth element (TRest). + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// The eighth element generator that accepts a random source. + /// Null or a generated value tuple. public static (T1, T2, T3, T4, T5, T6, T7, TRest)? NullableValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : struct => Nullable(random, random => ValueTuple(random, generator1, generator2, generator3, generator4, generator5, generator6, generator7, generator8)); + /// + /// Returns a nullable value generated by or null with approximately 34% probability. + /// + /// The value type. + /// The value generator. + /// A value or null. public static T? Nullable(Func generator) where T : struct => Chance(66) ? generator() : null; + /// + /// Returns a nullable value generated by using , or null with approximately 34% probability. + /// + /// The value type. + /// The random source to use. + /// The value generator that accepts a random source. + /// A value or null. public static T? Nullable(Random random, Func generator) where T : struct => Chance(random, 66) ? generator(random) : null; + /// + /// Returns a nullable reference type generated by or null (default) with approximately 34% probability. + /// + /// The reference type. + /// The value generator. + /// A reference value or null. public static T? NullableObject(Func generator) where T : notnull => Chance(66) ? generator() : default; + /// + /// Returns a nullable reference type generated by using , or null (default) with approximately 34% probability. + /// + /// The reference type. + /// The random source to use. + /// The value generator that accepts a random source. + /// A reference value or null. public static T? NullableObject(Random random, Func generator) where T : notnull => Chance(random, 66) ? generator(random) : default; diff --git a/src/JSSoft.Randora/RandomUtility.Tuple.cs b/src/JSSoft.Randora/RandomUtility.Tuple.cs index f6043bb..4734804 100644 --- a/src/JSSoft.Randora/RandomUtility.Tuple.cs +++ b/src/JSSoft.Randora/RandomUtility.Tuple.cs @@ -8,90 +8,496 @@ namespace JSSoft.Randora; public static partial class RandomUtility { + /// + /// Creates a Tuple of two elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The first element generator. + /// The second element generator. + /// A Tuple of two generated elements. public static Tuple Tuple(Func generator1, Func generator2) => new(generator1(), generator2()); + /// + /// Creates a Tuple of two elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// A Tuple of two generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2) => new(generator1(random), generator2(random)); + /// + /// Creates a Tuple of three elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// A Tuple of three generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3) => new(generator1(), generator2(), generator3()); + /// + /// Creates a Tuple of three elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// A Tuple of three generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3) => new(generator1(random), generator2(random), generator3(random)); + /// + /// Creates a Tuple of four elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// A Tuple of four generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3, Func generator4) => new(generator1(), generator2(), generator3(), generator4()); + /// + /// Creates a Tuple of four elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// A Tuple of four generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4) => new(generator1(random), generator2(random), generator3(random), generator4(random)); + /// + /// Creates a Tuple of five elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// A Tuple of five generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => new(generator1(), generator2(), generator3(), generator4(), generator5()); + /// + /// Creates a Tuple of five elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// A Tuple of five generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => new(generator1(random), generator2(random), generator3(random), generator4(random), generator5(random)); + /// + /// Creates a Tuple of six elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// A Tuple of six generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => new(generator1(), generator2(), generator3(), generator4(), generator5(), generator6()); + /// + /// Creates a Tuple of six elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// A Tuple of six generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => new(generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random)); + /// + /// Creates a Tuple of seven elements using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// A Tuple of seven generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => new(generator1(), generator2(), generator3(), generator4(), generator5(), generator6(), generator7()); + /// + /// Creates a Tuple of seven elements using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// A Tuple of seven generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => new(generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random), generator7(random)); + /// + /// Creates a Tuple of eight elements (eighth is TRest) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The eighth element type (TRest). + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// The eighth element generator. + /// A Tuple of eight generated elements. public static Tuple Tuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : notnull => new(generator1(), generator2(), generator3(), generator4(), generator5(), generator6(), generator7(), generator8()); + /// + /// Creates a Tuple of eight elements (eighth is TRest) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The eighth element type (TRest). + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// The eighth element generator that accepts a random source. + /// A Tuple of eight generated elements. public static Tuple Tuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : notnull => new(generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random), generator7(random), generator8(random)); + /// + /// Creates a value tuple (T1,T2) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The first element generator. + /// The second element generator. + /// A value tuple of two generated elements. public static (T1, T2) ValueTuple(Func generator1, Func generator2) => (generator1(), generator2()); + /// + /// Creates a value tuple (T1,T2) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// A value tuple of two generated elements. public static (T1, T2) ValueTuple(Random random, Func generator1, Func generator2) => (generator1(random), generator2(random)); + /// + /// Creates a value tuple (T1,T2,T3) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// A value tuple of three generated elements. public static (T1, T2, T3) ValueTuple(Func generator1, Func generator2, Func generator3) => (generator1(), generator2(), generator3()); + /// + /// Creates a value tuple (T1,T2,T3) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// A value tuple of three generated elements. public static (T1, T2, T3) ValueTuple(Random random, Func generator1, Func generator2, Func generator3) => (generator1(random), generator2(random), generator3(random)); + /// + /// Creates a value tuple (T1,T2,T3,T4) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// A value tuple of four generated elements. public static (T1, T2, T3, T4) ValueTuple(Func generator1, Func generator2, Func generator3, Func generator4) => (generator1(), generator2(), generator3(), generator4()); + /// + /// Creates a value tuple (T1,T2,T3,T4) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// A value tuple of four generated elements. public static (T1, T2, T3, T4) ValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4) => (generator1(random), generator2(random), generator3(random), generator4(random)); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// A value tuple of five generated elements. public static (T1, T2, T3, T4, T5) ValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => (generator1(), generator2(), generator3(), generator4(), generator5()); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// A value tuple of five generated elements. public static (T1, T2, T3, T4, T5) ValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5) => (generator1(random), generator2(random), generator3(random), generator4(random), generator5(random)); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5,T6) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// A value tuple of six generated elements. public static (T1, T2, T3, T4, T5, T6) ValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => (generator1(), generator2(), generator3(), generator4(), generator5(), generator6()); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5,T6) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// A value tuple of six generated elements. public static (T1, T2, T3, T4, T5, T6) ValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6) => (generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random)); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5,T6,T7) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// A value tuple of seven generated elements. public static (T1, T2, T3, T4, T5, T6, T7) ValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => (generator1(), generator2(), generator3(), generator4(), generator5(), generator6(), generator7()); + /// + /// Creates a value tuple (T1,T2,T3,T4,T5,T6,T7) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// A value tuple of seven generated elements. public static (T1, T2, T3, T4, T5, T6, T7) ValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7) => (generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random), generator7(random)); + /// + /// Creates a value tuple of eight elements (eighth is TRest) using the provided element generators and the shared random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The eighth element type (TRest). + /// The first element generator. + /// The second element generator. + /// The third element generator. + /// The fourth element generator. + /// The fifth element generator. + /// The sixth element generator. + /// The seventh element generator. + /// The eighth element generator. + /// A value tuple of eight generated elements. public static (T1, T2, T3, T4, T5, T6, T7, TRest) ValueTuple(Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : struct => (generator1(), generator2(), generator3(), generator4(), generator5(), generator6(), generator7(), generator8()); + /// + /// Creates a value tuple of eight elements (eighth is TRest) using the provided element generators and the specified random source. + /// + /// The first element type. + /// The second element type. + /// The third element type. + /// The fourth element type. + /// The fifth element type. + /// The sixth element type. + /// The seventh element type. + /// The eighth element type (TRest). + /// The random source to use. + /// The first element generator that accepts a random source. + /// The second element generator that accepts a random source. + /// The third element generator that accepts a random source. + /// The fourth element generator that accepts a random source. + /// The fifth element generator that accepts a random source. + /// The sixth element generator that accepts a random source. + /// The seventh element generator that accepts a random source. + /// The eighth element generator that accepts a random source. + /// A value tuple of eight generated elements. public static (T1, T2, T3, T4, T5, T6, T7, TRest) ValueTuple(Random random, Func generator1, Func generator2, Func generator3, Func generator4, Func generator5, Func generator6, Func generator7, Func generator8) where TRest : struct => (generator1(random), generator2(random), generator3(random), generator4(random), generator5(random), generator6(random), generator7(random), generator8(random)); diff --git a/src/JSSoft.Randora/RandomUtility.cs b/src/JSSoft.Randora/RandomUtility.cs index 8b378be..22e8ee0 100644 --- a/src/JSSoft.Randora/RandomUtility.cs +++ b/src/JSSoft.Randora/RandomUtility.cs @@ -11,6 +11,9 @@ namespace JSSoft.Randora; +/// +/// Provides utility methods for generating random values of various types. +/// public static partial class RandomUtility { public const int AttemptCount = 100; @@ -29,8 +32,15 @@ public static partial class RandomUtility private static readonly string[] Words = GetWords(); + /// + /// Generates a random value. + /// public static sbyte SByte() => SByte(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static sbyte SByte(Random random) { var bytes = new byte[1]; @@ -38,8 +48,15 @@ public static sbyte SByte(Random random) return (sbyte)bytes[0]; } + /// + /// Generates a random value. + /// public static byte Byte() => Byte(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static byte Byte(Random random) { var bytes = new byte[1]; @@ -47,12 +64,28 @@ public static byte Byte(Random random) return bytes[0]; } + /// + /// Generates a byte array of a random length within the default range. + /// public static byte[] Bytes() => Bytes(_shared); + /// + /// Generates a byte array with the specified length filled with random values. + /// + /// The number of bytes to generate. public static byte[] Bytes(int length) => Bytes(_shared, length); + /// + /// Generates a byte array of a random length within the default range using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static byte[] Bytes(Random random) => Bytes(random, Length(random)); + /// + /// Generates a byte array with the specified length using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The number of bytes to generate. public static byte[] Bytes(Random random, int length) { var bytes = new byte[length]; @@ -60,8 +93,15 @@ public static byte[] Bytes(Random random, int length) return bytes; } + /// + /// Generates a random value. + /// public static short Int16() => Int16(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static short Int16(Random random) { var bytes = new byte[2]; @@ -69,8 +109,15 @@ public static short Int16(Random random) return BitConverter.ToInt16(bytes, 0); } + /// + /// Generates a random value. + /// public static ushort UInt16() => UInt16(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static ushort UInt16(Random random) { var bytes = new byte[2]; @@ -78,16 +125,41 @@ public static ushort UInt16(Random random) return BitConverter.ToUInt16(bytes, 0); } + /// + /// Generates a random value. + /// public static int Int32() => Int32(_shared); + /// + /// Generates a random within the specified range. + /// + /// The inclusive lower bound. + /// The exclusive upper bound. public static int Int32(int minValue, int maxValue) => _shared.Next(minValue, maxValue); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int Int32(Random random) => Int32(random, int.MinValue, int.MaxValue); + /// + /// Generates a random within the specified range using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The inclusive lower bound. + /// The exclusive upper bound. public static int Int32(Random random, int minValue, int maxValue) => random.Next(minValue, maxValue); + /// + /// Generates a random value. + /// public static uint UInt32() => UInt32(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static uint UInt32(Random random) { var bytes = new byte[4]; @@ -95,16 +167,41 @@ public static uint UInt32(Random random) return BitConverter.ToUInt32(bytes, 0); } + /// + /// Generates a random value. + /// public static long Int64() => Int64(_shared); + /// + /// Generates a random within the specified range. + /// + /// The inclusive lower bound. + /// The exclusive upper bound. public static long Int64(long minValue, long maxValue) => _shared.NextInt64(minValue, maxValue); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static long Int64(Random random) => Int64(random, long.MinValue, long.MaxValue); + /// + /// Generates a random within the specified range using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The inclusive lower bound. + /// The exclusive upper bound. public static long Int64(Random random, long minValue, long maxValue) => random.NextInt64(minValue, maxValue); + /// + /// Generates a random value. + /// public static ulong UInt64() => UInt64(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static ulong UInt64(Random random) { var bytes = new byte[8]; @@ -112,8 +209,15 @@ public static ulong UInt64(Random random) return BitConverter.ToUInt64(bytes, 0); } + /// + /// Generates a random value. + /// public static float Single() => Single(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static float Single(Random random) { #if NET6_0_OR_GREATER @@ -123,16 +227,37 @@ public static float Single(Random random) #endif } + /// + /// Generates a random value. + /// public static double Double() => Double(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static double Double(Random random) => random.NextDouble(); + /// + /// Generates a random value. + /// public static decimal Decimal() => Decimal(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static decimal Decimal(Random random) => (decimal)random.NextDouble(); + /// + /// Generates a random value. + /// public static BigInteger BigInteger() => BigInteger(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static BigInteger BigInteger(Random random) { var length = Length(random, 1, 17); @@ -140,88 +265,209 @@ public static BigInteger BigInteger(Random random) return new BigInteger(bytes); } + /// + /// Generates a positive value (> 0). + /// public static int Positive() => Positive(_shared); + /// + /// Generates a positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int Positive(Random random) => Int32(random, 0, int.MaxValue) + 1; + /// + /// Generates a negative value (< 0). + /// public static int Negative() => Negative(_shared); + /// + /// Generates a negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int Negative(Random random) => Int32(random, int.MinValue, 0); + /// + /// Generates a non-positive value (<= 0). + /// public static int NonPositive() => NonPositive(_shared); + /// + /// Generates a non-positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int NonPositive(Random random) => Int32(random, int.MinValue, 1); + /// + /// Generates a non-negative value (>= 0). + /// public static int NonNegative() => NonNegative(_shared); + /// + /// Generates a non-negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int NonNegative(Random random) => Int32(random, -1, int.MaxValue) + 1; + /// + /// Generates a positive value (> 0). + /// public static long PositiveInt64() => PositiveInt64(_shared); + /// + /// Generates a positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static long PositiveInt64(Random random) => Int64(random, 0, long.MaxValue) + 1; + /// + /// Generates a negative value (< 0). + /// public static long NegativeInt64() => NegativeInt64(_shared); + /// + /// Generates a negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static long NegativeInt64(Random random) => Int64(random, long.MinValue, 0); + /// + /// Generates a non-positive value (<= 0). + /// public static long NonPositiveInt64() => NonPositiveInt64(_shared); + /// + /// Generates a non-positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static long NonPositiveInt64(Random random) => Int64(random, long.MinValue, 1); + /// + /// Generates a non-negative value (>= 0). + /// public static long NonNegativeInt64() => NonNegativeInt64(_shared); + /// + /// Generates a non-negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static long NonNegativeInt64(Random random) => Int64(random, -1, long.MaxValue) + 1; + /// + /// Generates a positive value (> 0). + /// public static BigInteger PositiveBigInteger() => PositiveBigInteger(_shared); + /// + /// Generates a positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static BigInteger PositiveBigInteger(Random random) { var v = BigInteger(random); return v.Sign > 0 ? v : -v; } + /// + /// Generates a negative value (< 0). + /// public static BigInteger NegativeBigInteger() => NegativeBigInteger(_shared); + /// + /// Generates a negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static BigInteger NegativeBigInteger(Random random) { var v = BigInteger(random); return v.Sign < 0 ? v : -v; } + /// + /// Generates a non-positive value (<= 0). + /// public static BigInteger NonPositiveBigInteger() => NonPositiveBigInteger(_shared); + /// + /// Generates a non-positive value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static BigInteger NonPositiveBigInteger(Random random) { var v = BigInteger(random); return v.Sign <= 0 ? v : -v; } + /// + /// Generates a non-negative value (>= 0). + /// public static BigInteger NonNegativeBigInteger() => NonNegativeBigInteger(_shared); + /// + /// Generates a non-negative value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static BigInteger NonNegativeBigInteger(Random random) { var v = BigInteger(random); return v.Sign >= 0 ? v : -v; } + /// + /// Returns a random word from the embedded dictionary. + /// public static string Word() => Word(_shared); + /// + /// Returns a random word using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static string Word(Random random) => Words[Int32(random, 0, Words.Length)]; + /// + /// Generates a hexadecimal string of random length within the default range. + /// public static string Hex() => Hex(_shared); + /// + /// Generates a hexadecimal string with the specified length. + /// + /// The number of hex characters to produce. public static string Hex(int length) => Hex(_shared, length); + /// + /// Generates a hexadecimal string of random length using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static string Hex(Random random) => Hex(random, Length(random)); + /// + /// Generates a hexadecimal string with the specified length using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The number of hex characters to produce. public static string Hex(Random random, int length) => Hex(Bytes(random, length)); + /// + /// Generates a random value. + /// public static char Char() => Char(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static char Char(Random random) => (char)UInt16(random); + /// + /// Generates a random value. + /// public static DateTimeOffset DateTimeOffset() => DateTimeOffset(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static DateTimeOffset DateTimeOffset(Random random) { var minValue = DateTime.UnixEpoch.Ticks; @@ -230,43 +476,111 @@ public static DateTimeOffset DateTimeOffset(Random random) return new DateTimeOffset(value, System.TimeSpan.Zero); } + /// + /// Generates a random value. + /// public static TimeSpan TimeSpan() => TimeSpan(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static TimeSpan TimeSpan(Random random) => new(random.NextInt64(new TimeSpan(365, 0, 0, 0).Ticks)); + /// + /// Generates a within the specified milliseconds range. + /// + /// The inclusive lower bound in milliseconds. + /// The exclusive upper bound in milliseconds. public static TimeSpan TimeSpan(int minMilliseconds, int maxMilliseconds) => TimeSpan(_shared, minMilliseconds, maxMilliseconds); + /// + /// Generates a within the specified milliseconds range using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The inclusive lower bound in milliseconds. + /// The exclusive upper bound in milliseconds. public static TimeSpan TimeSpan(Random random, int minMilliseconds, int maxMilliseconds) { var milliseconds = random.Next(minMilliseconds, maxMilliseconds); return System.TimeSpan.FromMilliseconds(milliseconds); } + /// + /// Generates a random value. + /// public static Guid Guid() => Guid(_shared); + /// + /// Generates a random value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static Guid Guid(Random random) => new(Array(random, Byte, 16)); + /// + /// Returns a random length within the default range. + /// public static int Length() => Length(_shared); + /// + /// Returns a random length between 1 (inclusive) and the specified maximum (exclusive). + /// + /// The exclusive upper bound. public static int Length(int maxLength) => Length(1, maxLength); + /// + /// Returns a random length within the specified range. + /// + /// The inclusive lower bound. + /// The exclusive upper bound. public static int Length(int minLength, int maxLength) => Length(_shared, minLength, maxLength); + /// + /// Returns a random length within the default range using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static int Length(Random random) => Length(random, 1, 10); + /// + /// Returns a random length between 1 (inclusive) and the specified maximum (exclusive) using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The exclusive upper bound. public static int Length(Random random, int maxLength) => Length(random, 1, maxLength); + /// + /// Returns a random length within the specified range using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The inclusive lower bound. + /// The exclusive upper bound. public static int Length(Random random, int minLength, int maxLength) => random.Next(minLength, maxLength); + /// + /// Generates a random boolean value. + /// public static bool Boolean() => Boolean(_shared); + /// + /// Generates a random boolean value using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static bool Boolean(Random random) => Int32(random, 0, 2) is 0; + /// + /// Returns a random enum value. Flags enums are not supported. + /// + /// The enum type. public static T Enum() where T : Enum => Enum(_shared); + /// + /// Returns a random enum value using the specified PRNG. Flags enums are not supported. + /// + /// The enum type. + /// The pseudo-random number generator to use. public static T Enum(Random random) where T : Enum { @@ -280,8 +594,15 @@ public static T Enum(Random random) return (T)values.GetValue(index)!; } + /// + /// Generates a random whitespace-separated string of words. + /// public static string String() => String(_shared); + /// + /// Generates a random whitespace-separated string of words using the specified PRNG. + /// + /// The pseudo-random number generator to use. public static string String(Random random) { var sb = new StringBuilder(); @@ -299,12 +620,36 @@ public static string String(Random random) return sb.ToString(); } + /// + /// Creates an array of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static T[] Array(Func generator) => Array(generator, Length()); + /// + /// Creates an array using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The number of elements. public static T[] Array(Func generator, int length) => Array(_shared, _ => generator(), length); + /// + /// Creates an array of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static T[] Array(Random random, Func generator) => Array(random, generator, Length(random)); + /// + /// Creates an array using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The number of elements. public static T[] Array(Random random, Func generator, int length) { var items = new T[length]; @@ -316,14 +661,38 @@ public static T[] Array(Random random, Func generator, int length) return items; } + /// + /// Creates a of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static List List(Func generator) => List(generator, Length()); + /// + /// Creates a using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The number of elements. public static List List(Func generator, int length) => List(_shared, _ => generator(), length); + /// + /// Creates a of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static List List(Random random, Func generator) => List(random, generator, Length(random)); + /// + /// Creates a using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The number of elements. public static List List(Random random, Func generator, int length) { var items = new T[length]; @@ -335,14 +704,38 @@ public static List List(Random random, Func generator, int leng return [.. items]; } + /// + /// Creates a of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static HashSet HashSet(Func generator) => HashSet(generator, Length()); + /// + /// Creates a using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The maximum number of unique elements to attempt to add. public static HashSet HashSet(Func generator, int length) => HashSet(_shared, _ => generator(), length); + /// + /// Creates a of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static HashSet HashSet(Random random, Func generator) => HashSet(random, generator, Length(random)); + /// + /// Creates a using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The maximum number of unique elements to attempt to add. public static HashSet HashSet(Random random, Func generator, int length) { var itemList = new List(length); @@ -359,14 +752,38 @@ public static HashSet HashSet(Random random, Func + /// Creates a of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static SortedSet SortedSet(Func generator) => SortedSet(generator, Length()); + /// + /// Creates a using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The maximum number of unique elements to attempt to add. public static SortedSet SortedSet(Func generator, int length) => SortedSet(_shared, _ => generator(), length); + /// + /// Creates a of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static SortedSet SortedSet(Random random, Func generator) => SortedSet(random, generator, Length(random)); + /// + /// Creates a using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The maximum number of unique elements to attempt to add. public static SortedSet SortedSet(Random random, Func generator, int length) { var itemList = new List(length); @@ -383,21 +800,53 @@ public static SortedSet SortedSet(Random random, Func + /// Creates a of random length using the specified key and value generators. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. public static Dictionary Dictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => Dictionary(keyGenerator, valueGenerator, Length()); + /// + /// Creates a using the specified key/value generators and length. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. + /// The maximum number of unique keys to attempt to add. public static Dictionary Dictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => Dictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); + /// + /// Creates a of random length using the specified PRNG and key/value generators. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. public static Dictionary Dictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => Dictionary(random, keyGenerator, valueGenerator, Length(random)); + /// + /// Creates a using the specified PRNG, key/value generators, and length. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. + /// The maximum number of unique keys to attempt to add. public static Dictionary Dictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull @@ -419,21 +868,53 @@ public static Dictionary Dictionary( return new Dictionary(itemList); } + /// + /// Creates a of random length using the specified key and value generators. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. public static SortedDictionary SortedDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => SortedDictionary(keyGenerator, valueGenerator, Length()); + /// + /// Creates a using the specified key/value generators and length. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. + /// The maximum number of unique keys to attempt to add. public static SortedDictionary SortedDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => SortedDictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); + /// + /// Creates a of random length using the specified PRNG and key/value generators. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. public static SortedDictionary SortedDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => SortedDictionary(random, keyGenerator, valueGenerator, Length(random)); + /// + /// Creates a using the specified PRNG, key/value generators, and length. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. + /// The maximum number of unique keys to attempt to add. public static SortedDictionary SortedDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull @@ -453,15 +934,39 @@ public static SortedDictionary SortedDictionary( return new SortedDictionary(dictionary); } + /// + /// Creates an of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static ImmutableArray ImmutableArray(Func generator) => ImmutableArray(generator, Length()); + /// + /// Creates an using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The number of elements. public static ImmutableArray ImmutableArray(Func generator, int length) => ImmutableArray(_shared, _ => generator(), length); + /// + /// Creates an of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static ImmutableArray ImmutableArray(Random random, Func generator) => ImmutableArray(random, generator, Length(random)); + /// + /// Creates an using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The number of elements. public static ImmutableArray ImmutableArray(Random random, Func generator, int length) { var items = new T[length]; @@ -473,15 +978,39 @@ public static ImmutableArray ImmutableArray(Random random, Func return System.Collections.Immutable.ImmutableArray.Create(items); } + /// + /// Creates an of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static ImmutableList ImmutableList(Func generator) => ImmutableList(generator, Length()); + /// + /// Creates an using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The number of elements. public static ImmutableList ImmutableList(Func generator, int length) => ImmutableList(_shared, _ => generator(), length); + /// + /// Creates an of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static ImmutableList ImmutableList(Random random, Func generator) => ImmutableList(random, generator, Length(random)); + /// + /// Creates an using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The number of elements. public static ImmutableList ImmutableList(Random random, Func generator, int length) { var items = new T[length]; @@ -493,15 +1022,39 @@ public static ImmutableList ImmutableList(Random random, Func g return System.Collections.Immutable.ImmutableList.Create(items); } + /// + /// Creates an of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static ImmutableHashSet ImmutableHashSet(Func generator) => ImmutableHashSet(generator, Length()); + /// + /// Creates an using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The maximum number of unique elements to attempt to add. public static ImmutableHashSet ImmutableHashSet(Func generator, int length) => ImmutableHashSet(_shared, _ => generator(), length); + /// + /// Creates an of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static ImmutableHashSet ImmutableHashSet(Random random, Func generator) => ImmutableHashSet(random, generator, Length(random)); + /// + /// Creates an using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The maximum number of unique elements to attempt to add. public static ImmutableHashSet ImmutableHashSet(Random random, Func generator, int length) { var itemList = new List(length); @@ -518,15 +1071,39 @@ public static ImmutableHashSet ImmutableHashSet(Random random, Func + /// Creates an of random length using the specified value generator. + /// + /// The element type. + /// A function that generates element values. public static ImmutableSortedSet ImmutableSortedSet(Func generator) => ImmutableSortedSet(generator, Length()); + /// + /// Creates an using the specified value generator and length. + /// + /// The element type. + /// A function that generates element values. + /// The maximum number of unique elements to attempt to add. public static ImmutableSortedSet ImmutableSortedSet(Func generator, int length) => ImmutableSortedSet(_shared, _ => generator(), length); + /// + /// Creates an of random length using the specified PRNG and value generator. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. public static ImmutableSortedSet ImmutableSortedSet(Random random, Func generator) => ImmutableSortedSet(random, generator, Length(random)); + /// + /// Creates an using the specified PRNG, value generator, and length. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// A function that generates element values given a PRNG. + /// The maximum number of unique elements to attempt to add. public static ImmutableSortedSet ImmutableSortedSet(Random random, Func generator, int length) { var itemList = new List(length); @@ -543,21 +1120,53 @@ public static ImmutableSortedSet ImmutableSortedSet(Random random, Func + /// Creates an of random length using the specified key and value generators. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. public static ImmutableDictionary ImmutableDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => ImmutableDictionary(keyGenerator, valueGenerator, Length()); + /// + /// Creates an using the specified key/value generators and length. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. + /// The maximum number of unique keys to attempt to add. public static ImmutableDictionary ImmutableDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => ImmutableDictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); + /// + /// Creates an of random length using the specified PRNG and key/value generators. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. public static ImmutableDictionary ImmutableDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => ImmutableDictionary(random, keyGenerator, valueGenerator, Length(random)); + /// + /// Creates an using the specified PRNG, key/value generators, and length. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. + /// The maximum number of unique keys to attempt to add. public static ImmutableDictionary ImmutableDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull @@ -579,21 +1188,53 @@ public static ImmutableDictionary ImmutableDictionary + /// Creates an of random length using the specified key and value generators. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. public static ImmutableSortedDictionary ImmutableSortedDictionary( Func keyGenerator, Func valueGenerator) where TKey : notnull => ImmutableSortedDictionary(keyGenerator, valueGenerator, Length()); + /// + /// Creates an using the specified key/value generators and length. + /// + /// The key type. + /// The value type. + /// A function that generates keys. + /// A function that generates values. + /// The maximum number of unique keys to attempt to add. public static ImmutableSortedDictionary ImmutableSortedDictionary( Func keyGenerator, Func valueGenerator, int length) where TKey : notnull => ImmutableSortedDictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); + /// + /// Creates an of random length using the specified PRNG and key/value generators. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. public static ImmutableSortedDictionary ImmutableSortedDictionary( Random random, Func keyGenerator, Func valueGenerator) where TKey : notnull => ImmutableSortedDictionary(random, keyGenerator, valueGenerator, Length(random)); + /// + /// Creates an using the specified PRNG, key/value generators, and length. + /// + /// The key type. + /// The value type. + /// The pseudo-random number generator to use. + /// A function that generates keys given a PRNG. + /// A function that generates values given a PRNG. + /// The maximum number of unique keys to attempt to add. public static ImmutableSortedDictionary ImmutableSortedDictionary( Random random, Func keyGenerator, Func valueGenerator, int length) where TKey : notnull @@ -615,9 +1256,20 @@ public static ImmutableSortedDictionary ImmutableSortedDictionary< return System.Collections.Immutable.ImmutableSortedDictionary.CreateRange(itemList); } + /// + /// Returns a random element from the sequence, or the default value if the sequence is empty. + /// + /// The element type. + /// The source sequence. public static T? RandomOrDefault(this IEnumerable enumerable) => RandomOrDefault(enumerable, _shared); + /// + /// Returns a random element from the sequence using the specified PRNG, or the default value if the sequence is empty. + /// + /// The element type. + /// The source sequence. + /// The pseudo-random number generator to use. public static T? RandomOrDefault(this IEnumerable enumerable, Random random) { var count = 0; @@ -645,9 +1297,20 @@ public static ImmutableSortedDictionary ImmutableSortedDictionary< return default; } + /// + /// Returns a random element from the sequence. Throws if the sequence is empty. + /// + /// The element type. + /// The source sequence. public static T Random(this IEnumerable enumerable) => Random(enumerable, _shared); + /// + /// Returns a random element from the sequence using the specified PRNG. Throws if the sequence is empty. + /// + /// The element type. + /// The source sequence. + /// The pseudo-random number generator to use. public static T Random(this IEnumerable enumerable, Random random) { var count = 0; @@ -675,9 +1338,22 @@ public static T Random(this IEnumerable enumerable, Random random) throw new InvalidOperationException("Sequence contains no elements."); } + /// + /// Repeatedly executes the generator until the predicate is satisfied and returns the value. Throws if the maximum attempts are exceeded. + /// + /// The generated value type. + /// The value generator. + /// The predicate to test generated values. public static T Try(Func generator, Func predicate) => Try(_shared, _ => generator(), predicate); + /// + /// Repeatedly executes the generator with the specified PRNG until the predicate is satisfied. Throws if the maximum attempts are exceeded. + /// + /// The generated value type. + /// The pseudo-random number generator to use. + /// The value generator that accepts a PRNG. + /// The predicate to test generated values. public static T Try(Random random, Func generator, Func predicate) { var countByValue = new Dictionary(); @@ -705,8 +1381,17 @@ public static T Try(Random random, Func generator, Func p } } + /// + /// Returns true with the specified probability (0–100%). + /// + /// The probability in percent (0–100). public static bool Chance(int probability) => Chance(_shared, probability); + /// + /// Returns true with the specified probability (0–100%) using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The probability in percent (0–100). public static bool Chance(Random random, int probability) { if (probability < 0 || probability > 100) @@ -717,8 +1402,17 @@ public static bool Chance(Random random, int probability) return random.Next(0, 100) < probability; } + /// + /// Returns true with the specified probability (0.0–1.0). + /// + /// The probability between 0.0 and 1.0. public static bool Chance(double probability) => Chance(_shared, probability); + /// + /// Returns true with the specified probability (0.0–1.0) using the provided PRNG. + /// + /// The pseudo-random number generator to use. + /// The probability between 0.0 and 1.0. public static bool Chance(Random random, double probability) { if (probability < 0.0 || probability > 1.0) @@ -729,9 +1423,20 @@ public static bool Chance(Random random, double probability) return random.NextDouble() < probability; } + /// + /// Returns the sequence ordered in a random order. + /// + /// The element type. + /// The source sequence. public static IOrderedEnumerable Shuffle(IEnumerable source) => Shuffle(_shared, source); + /// + /// Returns the sequence ordered in a random order using the specified PRNG. + /// + /// The element type. + /// The pseudo-random number generator to use. + /// The source sequence. public static IOrderedEnumerable Shuffle(Random random, IEnumerable source) => source.OrderBy(_ => random.Next()); @@ -821,6 +1526,9 @@ private static string Hex(ReadOnlySpan bytes) #endif } + /// + /// The exception thrown when the maximum number of attempts to find a value matching the predicate is exceeded. + /// public sealed class MaxAttemptsExceededException(int maxAttempts) : InvalidOperationException($"No value was found that matches the condition after {maxAttempts} attempts.") { From e0c265e0da4d3d959bf48b34fac46a4a91d8d71f Mon Sep 17 00:00:00 2001 From: s2quake Date: Sun, 2 Nov 2025 13:08:35 +0900 Subject: [PATCH 2/5] build(pack): condition pack-only settings at PropertyGroup level - Multi-target only during pack - Generate XML docs only when packing - Keep dev builds single-target - Include .xml in nupkg output --- src/Directory.Build.props | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 691f903..e4c214f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -4,9 +4,17 @@ library - net6.0;net7.0;net8.0;net9.0;netstandard2.1 - net9.0 - $(TestFramework) + + + + net6.0;net7.0;net8.0;net9.0;netstandard2.1 + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.xml + + + + net9.0 + $(TestFramework) From 4196faa04550308dd1b8e466d780bd903a820e16 Mon Sep 17 00:00:00 2001 From: s2quake Date: Sun, 2 Nov 2025 13:14:00 +0900 Subject: [PATCH 3/5] docs: add PR description for XML docs + pack-only config --- PR_BODY.md | 23 +++++++++++++++++++++++ src/Directory.Build.props | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 PR_BODY.md diff --git a/PR_BODY.md b/PR_BODY.md new file mode 100644 index 0000000..829b3d8 --- /dev/null +++ b/PR_BODY.md @@ -0,0 +1,23 @@ +# Docs: XML IntelliSense + pack-only doc generation + +This PR improves developer experience and packaging: + +## Summary +- Translate and complete XML documentation for all public APIs in `RandomUtility`, `RandomUtility.Nullable`, and `RandomUtility.Tuple`. +- Enable XML documentation generation only during `dotnet pack` to avoid stray XML outputs in dev builds, while ensuring IntelliSense docs ship in the NuGet package. +- Keep dev builds single-target for faster inner-loop; pack remains multi-target. + +## Changes +- docs(random): translate and complete XML docs for RandomUtility, Nullable, and Tuple +- build(pack): condition pack-only settings at PropertyGroup level + - Multi-target only during pack + - Generate XML docs only when packing + - Include .xml in nupkg output + +## CI/Release context (existing on main) +- Code coverage collection via coverlet and upload to Codecov (matrix by TFM) +- Test reporting via `dorny/test-reporter` using TRX + +## Notes +- No functional code changes; documentation-only plus build configuration for packaging. +- Validated with `dotnet build` and `dotnet pack`; nupkg contains XML docs next to assemblies. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e4c214f..69b6cc9 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -12,7 +12,7 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.xml - + net9.0 $(TestFramework) From b560d685e45a703ad509326955e0fe2777071b52 Mon Sep 17 00:00:00 2001 From: s2quake Date: Sun, 2 Nov 2025 13:27:19 +0900 Subject: [PATCH 4/5] docs(xml): disambiguate cref to generic collection types - Fully qualify List/HashSet/SortedSet/Dictionary cref targets to System.Collections.Generic - Fixes CS0419 ambiguity with method overloads in XML docs --- src/JSSoft.Randora/RandomUtility.cs | 80 +++++++++++++++-------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/JSSoft.Randora/RandomUtility.cs b/src/JSSoft.Randora/RandomUtility.cs index 22e8ee0..96879ed 100644 --- a/src/JSSoft.Randora/RandomUtility.cs +++ b/src/JSSoft.Randora/RandomUtility.cs @@ -16,6 +16,10 @@ namespace JSSoft.Randora; /// public static partial class RandomUtility { + /// + /// The maximum number of attempts the Try methods will perform to produce a value + /// that satisfies the predicate before throwing an exception. + /// public const int AttemptCount = 100; private static readonly char[] _hexCharacters = @@ -250,12 +254,12 @@ public static float Single(Random random) public static decimal Decimal(Random random) => (decimal)random.NextDouble(); /// - /// Generates a random value. + /// Generates a random value. /// public static BigInteger BigInteger() => BigInteger(_shared); /// - /// Generates a random value using the specified PRNG. + /// Generates a random value using the specified PRNG. /// /// The pseudo-random number generator to use. public static BigInteger BigInteger(Random random) @@ -354,12 +358,12 @@ public static BigInteger BigInteger(Random random) public static long NonNegativeInt64(Random random) => Int64(random, -1, long.MaxValue) + 1; /// - /// Generates a positive value (> 0). + /// Generates a positive value (> 0). /// public static BigInteger PositiveBigInteger() => PositiveBigInteger(_shared); /// - /// Generates a positive value using the specified PRNG. + /// Generates a positive value using the specified PRNG. /// /// The pseudo-random number generator to use. public static BigInteger PositiveBigInteger(Random random) @@ -369,12 +373,12 @@ public static BigInteger PositiveBigInteger(Random random) } /// - /// Generates a negative value (< 0). + /// Generates a negative value (< 0). /// public static BigInteger NegativeBigInteger() => NegativeBigInteger(_shared); /// - /// Generates a negative value using the specified PRNG. + /// Generates a negative value using the specified PRNG. /// /// The pseudo-random number generator to use. public static BigInteger NegativeBigInteger(Random random) @@ -384,12 +388,12 @@ public static BigInteger NegativeBigInteger(Random random) } /// - /// Generates a non-positive value (<= 0). + /// Generates a non-positive value (<= 0). /// public static BigInteger NonPositiveBigInteger() => NonPositiveBigInteger(_shared); /// - /// Generates a non-positive value using the specified PRNG. + /// Generates a non-positive value using the specified PRNG. /// /// The pseudo-random number generator to use. public static BigInteger NonPositiveBigInteger(Random random) @@ -399,12 +403,12 @@ public static BigInteger NonPositiveBigInteger(Random random) } /// - /// Generates a non-negative value (>= 0). + /// Generates a non-negative value (>= 0). /// public static BigInteger NonNegativeBigInteger() => NonNegativeBigInteger(_shared); /// - /// Generates a non-negative value using the specified PRNG. + /// Generates a non-negative value using the specified PRNG. /// /// The pseudo-random number generator to use. public static BigInteger NonNegativeBigInteger(Random random) @@ -460,12 +464,12 @@ public static BigInteger NonNegativeBigInteger(Random random) public static char Char(Random random) => (char)UInt16(random); /// - /// Generates a random value. + /// Generates a random value. /// public static DateTimeOffset DateTimeOffset() => DateTimeOffset(_shared); /// - /// Generates a random value using the specified PRNG. + /// Generates a random value using the specified PRNG. /// /// The pseudo-random number generator to use. public static DateTimeOffset DateTimeOffset(Random random) @@ -477,18 +481,18 @@ public static DateTimeOffset DateTimeOffset(Random random) } /// - /// Generates a random value. + /// Generates a random value. /// public static TimeSpan TimeSpan() => TimeSpan(_shared); /// - /// Generates a random value using the specified PRNG. + /// Generates a random value using the specified PRNG. /// /// The pseudo-random number generator to use. public static TimeSpan TimeSpan(Random random) => new(random.NextInt64(new TimeSpan(365, 0, 0, 0).Ticks)); /// - /// Generates a within the specified milliseconds range. + /// Generates a within the specified milliseconds range. /// /// The inclusive lower bound in milliseconds. /// The exclusive upper bound in milliseconds. @@ -496,7 +500,7 @@ public static TimeSpan TimeSpan(int minMilliseconds, int maxMilliseconds) => TimeSpan(_shared, minMilliseconds, maxMilliseconds); /// - /// Generates a within the specified milliseconds range using the provided PRNG. + /// Generates a within the specified milliseconds range using the provided PRNG. /// /// The pseudo-random number generator to use. /// The inclusive lower bound in milliseconds. @@ -508,12 +512,12 @@ public static TimeSpan TimeSpan(Random random, int minMilliseconds, int maxMilli } /// - /// Generates a random value. + /// Generates a random value. /// public static Guid Guid() => Guid(_shared); /// - /// Generates a random value using the specified PRNG. + /// Generates a random value using the specified PRNG. /// /// The pseudo-random number generator to use. public static Guid Guid(Random random) => new(Array(random, Byte, 16)); @@ -662,14 +666,14 @@ public static T[] Array(Random random, Func generator, int length) } /// - /// Creates a of random length using the specified value generator. + /// Creates a of random length using the specified value generator. /// /// The element type. /// A function that generates element values. public static List List(Func generator) => List(generator, Length()); /// - /// Creates a using the specified value generator and length. + /// Creates a using the specified value generator and length. /// /// The element type. /// A function that generates element values. @@ -678,7 +682,7 @@ public static List List(Func generator, int length) => List(_shared, _ => generator(), length); /// - /// Creates a of random length using the specified PRNG and value generator. + /// Creates a of random length using the specified PRNG and value generator. /// /// The element type. /// The pseudo-random number generator to use. @@ -687,7 +691,7 @@ public static List List(Random random, Func generator) => List(random, generator, Length(random)); /// - /// Creates a using the specified PRNG, value generator, and length. + /// Creates a using the specified PRNG, value generator, and length. /// /// The element type. /// The pseudo-random number generator to use. @@ -705,14 +709,14 @@ public static List List(Random random, Func generator, int leng } /// - /// Creates a of random length using the specified value generator. + /// Creates a of random length using the specified value generator. /// /// The element type. /// A function that generates element values. public static HashSet HashSet(Func generator) => HashSet(generator, Length()); /// - /// Creates a using the specified value generator and length. + /// Creates a using the specified value generator and length. /// /// The element type. /// A function that generates element values. @@ -721,7 +725,7 @@ public static HashSet HashSet(Func generator, int length => HashSet(_shared, _ => generator(), length); /// - /// Creates a of random length using the specified PRNG and value generator. + /// Creates a of random length using the specified PRNG and value generator. /// /// The element type. /// The pseudo-random number generator to use. @@ -730,7 +734,7 @@ public static HashSet HashSet(Random random, Func HashSet(random, generator, Length(random)); /// - /// Creates a using the specified PRNG, value generator, and length. + /// Creates a using the specified PRNG, value generator, and length. /// /// The element type. /// The pseudo-random number generator to use. @@ -753,14 +757,14 @@ public static HashSet HashSet(Random random, Func - /// Creates a of random length using the specified value generator. + /// Creates a of random length using the specified value generator. /// /// The element type. /// A function that generates element values. public static SortedSet SortedSet(Func generator) => SortedSet(generator, Length()); /// - /// Creates a using the specified value generator and length. + /// Creates a using the specified value generator and length. /// /// The element type. /// A function that generates element values. @@ -769,7 +773,7 @@ public static SortedSet SortedSet(Func generator, int le => SortedSet(_shared, _ => generator(), length); /// - /// Creates a of random length using the specified PRNG and value generator. + /// Creates a of random length using the specified PRNG and value generator. /// /// The element type. /// The pseudo-random number generator to use. @@ -778,7 +782,7 @@ public static SortedSet SortedSet(Random random, Func SortedSet(random, generator, Length(random)); /// - /// Creates a using the specified PRNG, value generator, and length. + /// Creates a using the specified PRNG, value generator, and length. /// /// The element type. /// The pseudo-random number generator to use. @@ -801,7 +805,7 @@ public static SortedSet SortedSet(Random random, Func - /// Creates a of random length using the specified key and value generators. + /// Creates a of random length using the specified key and value generators. /// /// The key type. /// The value type. @@ -813,7 +817,7 @@ public static Dictionary Dictionary( => Dictionary(keyGenerator, valueGenerator, Length()); /// - /// Creates a using the specified key/value generators and length. + /// Creates a using the specified key/value generators and length. /// /// The key type. /// The value type. @@ -826,7 +830,7 @@ public static Dictionary Dictionary( => Dictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); /// - /// Creates a of random length using the specified PRNG and key/value generators. + /// Creates a of random length using the specified PRNG and key/value generators. /// /// The key type. /// The value type. @@ -839,7 +843,7 @@ public static Dictionary Dictionary( => Dictionary(random, keyGenerator, valueGenerator, Length(random)); /// - /// Creates a using the specified PRNG, key/value generators, and length. + /// Creates a using the specified PRNG, key/value generators, and length. /// /// The key type. /// The value type. @@ -869,7 +873,7 @@ public static Dictionary Dictionary( } /// - /// Creates a of random length using the specified key and value generators. + /// Creates a of random length using the specified key and value generators. /// /// The key type. /// The value type. @@ -881,7 +885,7 @@ public static SortedDictionary SortedDictionary( => SortedDictionary(keyGenerator, valueGenerator, Length()); /// - /// Creates a using the specified key/value generators and length. + /// Creates a using the specified key/value generators and length. /// /// The key type. /// The value type. @@ -894,7 +898,7 @@ public static SortedDictionary SortedDictionary( => SortedDictionary(_shared, _ => keyGenerator(), _ => valueGenerator(), length); /// - /// Creates a of random length using the specified PRNG and key/value generators. + /// Creates a of random length using the specified PRNG and key/value generators. /// /// The key type. /// The value type. @@ -907,7 +911,7 @@ public static SortedDictionary SortedDictionary( => SortedDictionary(random, keyGenerator, valueGenerator, Length(random)); /// - /// Creates a using the specified PRNG, key/value generators, and length. + /// Creates a using the specified PRNG, key/value generators, and length. /// /// The key type. /// The value type. From 25f3f73e445c2cb556e6a131e0bf0e29035558bb Mon Sep 17 00:00:00 2001 From: s2quake Date: Sun, 2 Nov 2025 13:50:21 +0900 Subject: [PATCH 5/5] chore(version): bump FileVersion to 1.0.1 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 450d029..00025c4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,7 +21,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 1.0 - 1.0.0 + 1.0.1 $(FileVersion) git https://github.com/s2quake/randora