diff --git a/src/main/DryFish.ILib.Random.csproj b/src/main/DryFish.ILib.Random.csproj
index d7ce7f6..ad69095 100644
--- a/src/main/DryFish.ILib.Random.csproj
+++ b/src/main/DryFish.ILib.Random.csproj
@@ -1,28 +1,61 @@
-
- net8.0;net6.0;netstandard2.0;net462
- enable
+
+ net8.0;net7.0;net6.0;netstandard2.0;net48;net472;net462
+
enable
- true
+ enable
+ 10.0
+
+
DryFish.ILib.Random
2026.1.0
DryFish
- Random generation utilities for DryFish.ILib
- random;utility;dryfish;ilib
- MIT
+ DryFish
+ Random generation utilities for DryFish.ILib - strings, numbers, characters, colors, dates and more. Supports .NET 6/7/8, .NET Standard 2.0, and .NET Framework 4.6.2+.
+ random;utility;generation;dryfish;ilib;dotnet;cross-platform;randomizer
https://github.com/dryfish09/ILib.Random
+ MIT
+
+
+ README.md
+
+
+ true
+
+
+ true
+ snupkg
+
+
+ false
+ ../nupkg
-
-
- enable
+
+
+ $(DefineConstants);NET6_0_OR_GREATER
-
-
-
- disable
- 8.0
+
+
+
+ $(DefineConstants);NETFRAMEWORK
+ $(NoWarn);CS8600;CS8602;CS8603;CS8604;CS8618;CS8625
+
+
+ $(DefineConstants);NETSTANDARD
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/ILibRandom.cs b/src/main/ILibRandom.cs
index 47ed12b..befeec2 100644
--- a/src/main/ILibRandom.cs
+++ b/src/main/ILibRandom.cs
@@ -1,113 +1,169 @@
-namespace DryFish.ILib.Random;
+using System;
+using System.Collections.Generic;
-public static class ILibRandom
+namespace DryFish.ILib.Random
{
- private static readonly Random _random = new Random();
-
///
- /// Returns a random element from the specified array
+ /// Random generation utilities for DryFish.ILib
///
- /// Array of strings
- /// Random element from array
- public static string IRandomFromArray(string[] array)
+ public static class ILibRandom
{
- if (array == null || array.Length == 0)
- throw new ArgumentException("Array cannot be null or empty");
-
- return array[_random.Next(array.Length)];
- }
-
- ///
- /// Returns a random element from the specified array (generic)
- ///
- /// Type of array elements
- /// Array of type T
- /// Random element from array
- public static T IRandomFromArray(T[] array)
- {
- if (array == null || array.Length == 0)
- throw new ArgumentException("Array cannot be null or empty");
-
- return array[_random.Next(array.Length)];
- }
-
- ///
- /// Returns a random integer between min and max (inclusive)
- ///
- /// Minimum value
- /// Maximum value
- /// Random integer
- public static int IRandomInt(int min, int max) => _random.Next(min, max + 1);
-
- ///
- /// Returns a random integer between 0 and 100
- ///
- public static int IRandomInt() => _random.Next(101);
-
- ///
- /// Returns a random character between min and max
- ///
- /// Minimum character
- /// Maximum character
- /// Random character
- public static char IRandomChar(char min, char max) => (char)_random.Next(min, max + 1);
-
- ///
- /// Returns a random alphabet character between min and max
- ///
- /// Minimum alphabet (e.g., 'A')
- /// Maximum alphabet (e.g., 'Z')
- /// Random alphabet character
- public static char IRandomAlphabet(char min, char max)
- {
- if (!char.IsLetter(min) || !char.IsLetter(max))
- throw new ArgumentException("Only alphabet characters allowed");
-
- return (char)_random.Next(min, max + 1);
- }
-
- ///
- /// Returns a random uppercase letter (A-Z)
- ///
- public static char IRandomUppercase() => (char)_random.Next('A', 'Z' + 1);
-
- ///
- /// Returns a random lowercase letter (a-z)
- ///
- public static char IRandomLowercase() => (char)_random.Next('a', 'z' + 1);
-
- ///
- /// Returns a random boolean value
- ///
- public static bool IRandomBool() => _random.Next(2) == 1;
-
- ///
- /// Returns a random long between min and max
- ///
- public static long IRandomLong(long min, long max)
- {
- if (min > max) throw new ArgumentException("min must be <= max");
- long range = max - min;
- long rand = (long)(_random.NextDouble() * (range + 1));
- return min + rand;
- }
-
- ///
- /// Returns a random double between min and max
- ///
- public static double IRandomDouble(double min = 0.0, double max = 1.0)
- {
- if (min > max) throw new ArgumentException("min must be <= max");
- return min + (_random.NextDouble() * (max - min));
- }
-
- ///
- /// Returns a random item from a list
- ///
- public static T IRandomItem(IList list)
- {
- if (list == null || list.Count == 0)
- throw new ArgumentException("List cannot be null or empty");
- return list[_random.Next(list.Count)];
+ private static readonly System.Random _random = new System.Random();
+
+ ///
+ /// Returns a random element from the specified array
+ ///
+ /// Array of strings
+ /// Random element from array
+ public static string IRandomFromArray(string[] array)
+ {
+ if (array == null || array.Length == 0)
+ throw new ArgumentException("Array cannot be null or empty");
+
+ return array[_random.Next(array.Length)];
+ }
+
+ ///
+ /// Returns a random element from the specified array (generic)
+ ///
+ /// Type of array elements
+ /// Array of type T
+ /// Random element from array
+ public static T IRandomFromArray(T[] array)
+ {
+ if (array == null || array.Length == 0)
+ throw new ArgumentException("Array cannot be null or empty");
+
+ return array[_random.Next(array.Length)];
+ }
+
+ ///
+ /// Returns a random integer between min and max (inclusive)
+ ///
+ /// Minimum value
+ /// Maximum value
+ /// Random integer
+ public static int IRandomInt(int min, int max)
+ {
+ return _random.Next(min, max + 1);
+ }
+
+ ///
+ /// Returns a random integer between 0 and 100
+ ///
+ public static int IRandomInt()
+ {
+ return _random.Next(101);
+ }
+
+ ///
+ /// Returns a random character between min and max
+ ///
+ /// Minimum character
+ /// Maximum character
+ /// Random character
+ public static char IRandomChar(char min, char max)
+ {
+ return (char)_random.Next(min, max + 1);
+ }
+
+ ///
+ /// Returns a random alphabet character between min and max
+ ///
+ /// Minimum alphabet (e.g., 'A')
+ /// Maximum alphabet (e.g., 'Z')
+ /// Random alphabet character
+ public static char IRandomAlphabet(char min, char max)
+ {
+ if (!char.IsLetter(min) || !char.IsLetter(max))
+ throw new ArgumentException("Only alphabet characters allowed");
+
+ return (char)_random.Next(min, max + 1);
+ }
+
+ ///
+ /// Returns a random uppercase letter (A-Z)
+ ///
+ public static char IRandomUppercase()
+ {
+ return (char)_random.Next('A', 'Z' + 1);
+ }
+
+ ///
+ /// Returns a random lowercase letter (a-z)
+ ///
+ public static char IRandomLowercase()
+ {
+ return (char)_random.Next('a', 'z' + 1);
+ }
+
+ ///
+ /// Returns a random boolean value
+ ///
+ public static bool IRandomBool()
+ {
+ return _random.Next(2) == 1;
+ }
+
+ ///
+ /// Returns a random long between min and max
+ ///
+ public static long IRandomLong(long min, long max)
+ {
+ if (min > max) throw new ArgumentException("min must be <= max");
+ long range = max - min;
+ long rand = (long)(_random.NextDouble() * (range + 1));
+ return min + rand;
+ }
+
+ ///
+ /// Returns a random double between min and max
+ ///
+ public static double IRandomDouble(double min = 0.0, double max = 1.0)
+ {
+ if (min > max) throw new ArgumentException("min must be <= max");
+ return min + (_random.NextDouble() * (max - min));
+ }
+
+ ///
+ /// Returns a random item from a list
+ ///
+ /// Type of list elements
+ /// List of type T
+ /// Random item from list
+ public static T IRandomItem(IList list)
+ {
+ if (list == null || list.Count == 0)
+ throw new ArgumentException("List cannot be null or empty");
+ return list[_random.Next(list.Count)];
+ }
+
+ ///
+ /// Returns a random GUID as string
+ ///
+ public static string IRandomGuid()
+ {
+ return System.Guid.NewGuid().ToString();
+ }
+
+ ///
+ /// Returns a random hex color code (e.g., #FF5733)
+ ///
+ public static string IRandomHexColor()
+ {
+ return $"#{_random.Next(0x1000000):X6}";
+ }
+
+ ///
+ /// Returns a random console color name supported by ILib
+ ///
+ public static string IRandomConsoleColor()
+ {
+ string[] colors = { "black", "darkblue", "darkgreen", "darkcyan", "darkred",
+ "darkmagenta", "darkyellow", "gray", "grey", "darkgray",
+ "darkgrey", "blue", "green", "cyan", "red", "magenta",
+ "yellow", "white" };
+ return IRandomFromArray(colors);
+ }
}
}
diff --git a/src/test/DryFish.ILib.Random.Test.csproj b/src/test/DryFish.ILib.Random.Test.csproj
index 675f691..ede961b 100644
--- a/src/test/DryFish.ILib.Random.Test.csproj
+++ b/src/test/DryFish.ILib.Random.Test.csproj
@@ -1,9 +1,9 @@
-
net8.0
- enable
enable
+ enable
+ 10.0
false
@@ -17,8 +17,6 @@
-
-
diff --git a/src/test/ILib.RandomTest.cs b/src/test/ILib.RandomTest.cs
index 7d8f91c..66c18d6 100644
--- a/src/test/ILib.RandomTest.cs
+++ b/src/test/ILib.RandomTest.cs
@@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using DryFish.ILib.Random
+using DryFish.ILib.Random;
namespace DryFish.ILib.Random.Tests;