1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 03:05:42 +00:00

Remove internal Random in favour of static Shared

This commit is contained in:
Oliver Booth 2022-04-20 17:02:35 +01:00
parent 684fba043f
commit b6ec67d91f
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
3 changed files with 5 additions and 10 deletions

View File

@ -30,7 +30,7 @@ public static class ListExtensions
throw new ArgumentNullException(nameof(source));
}
random ??= RandomExtensions.Random;
random ??= System.Random.Shared;
return random.NextFrom(source);
}
@ -51,7 +51,7 @@ public static class ListExtensions
throw new ArgumentNullException(nameof(source));
}
random ??= RandomExtensions.Random;
random ??= System.Random.Shared;
int count = source.Count;
while (count > 0)

View File

@ -9,8 +9,6 @@ namespace X10D;
/// </summary>
public static class RandomExtensions
{
internal static readonly Random Random = new();
/// <summary>
/// Returns a random value that defined in a specified enum.
/// </summary>

View File

@ -317,11 +317,6 @@ public static class StringExtensions
throw new ArgumentNullException(nameof(source));
}
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
if (length < 0)
{
throw new ArgumentOutOfRangeException(nameof(length), ExceptionMessages.LengthGreaterThanOrEqualTo0);
@ -331,6 +326,8 @@ public static class StringExtensions
{
return string.Empty;
}
random ??= Random.Shared;
char[] array = source.ToCharArray();
var builder = new StringBuilder(length);
@ -411,7 +408,7 @@ public static class StringExtensions
/// <returns>Returns a <see cref="string" /> containing the characters in <paramref name="value" />, rearranged.</returns>
public static string Shuffled(this string value)
{
return value.Shuffled(RandomExtensions.Random);
return value.Shuffled(Random.Shared);
}
/// <summary>