Browse Source
Use `Random.Shared.Shuffle` if possible.
pull/21089/head
maliming
2 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
7 additions and
2 deletions
-
framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs
|
|
|
@ -103,10 +103,15 @@ public static class RandomHelper |
|
|
|
/// <param name="items">items</param>
|
|
|
|
public static List<T> GenerateRandomizedList<T>([NotNull] IEnumerable<T> items) |
|
|
|
{ |
|
|
|
var array = items.ToArray(); |
|
|
|
#if NETSTANDARD2_0 || NETSTANDARD2_1
|
|
|
|
return items.Shuffle(Rnd).ToList(); |
|
|
|
lock (Rnd) |
|
|
|
{ |
|
|
|
return array.Shuffle(Rnd).ToList(); |
|
|
|
} |
|
|
|
#else
|
|
|
|
return items.Shuffle(Random.Shared).ToList(); |
|
|
|
Random.Shared.Shuffle(array); |
|
|
|
return array.ToList(); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
|