1 type derived from Random
System.Private.CoreLib (1)
src\libraries\System.Private.CoreLib\src\System\Random.cs (1)
360private sealed class ThreadSafeRandom : Random
26 instantiations of Random
HttpStress (1)
Program.cs (1)
636_random = new Random(Combine(seed, taskNum)); // derived from global seed and worker number
ILCompiler.DependencyAnalysisFramework (1)
DependencyAnalyzer.cs (1)
112stackPopRandomizer = new Random(seed);
KeyManagementSimulator (2)
Program.cs (2)
93var productRandom = new Random(seed); 94var simulatorRandom = new Random(productRandom.Next());
Microsoft.Arcade.Common (1)
ExponentialRetry.cs (1)
13private Random _random = new Random();
Microsoft.AspNetCore.Components.Server.Tests (2)
Circuits\RemoteJSDataStreamTest.cs (2)
52var random = new Random(); 80var random = new Random();
Microsoft.AspNetCore.InternalTesting.Tests (1)
QuarantinedTestAttributeTest.cs (1)
27Assert.True(new Random().Next(100) <= 80);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (2)
BufferWriterTests.cs (1)
217new Random(length).NextBytes(data);
src\Shared\test\Shared.Tests\runtime\Http2\HuffmanDecodingTests.cs (1)
133new Random(42).NextBytes(data);
Microsoft.AspNetCore.Shared.Tests (1)
runtime\Http2\HuffmanDecodingTests.cs (1)
133new Random(42).NextBytes(data);
Microsoft.Build.Engine.UnitTests (2)
BuildEventArgsSerialization_Tests.cs (1)
471(AssemblyLoadingContext)(new Random().Next(Enum.GetNames(typeof(AssemblyLoadingContext)).Length));
Evaluation\Expander_Tests.cs (1)
1587xmlattribute.Value = "abc123" + new Random().Next();
Microsoft.Build.Framework (1)
StringUtils.cs (1)
25Random random = new();
Microsoft.Build.Framework.UnitTests (1)
AssemblyLoadBuildEventArgs_Tests.cs (1)
22(AssemblyLoadingContext)(new Random().Next(Enum.GetNames(typeof(AssemblyLoadingContext)).Length));
Microsoft.DotNet.Helix.Sdk (1)
AzureDevOpsTask.cs (1)
168private static readonly Random s_rand = new Random();
Microsoft.Extensions.Caching.Hybrid.Tests (3)
DistributedCacheTests.cs (3)
68new Random().NextBytes(expected); 114new Random().NextBytes(expected); 271var rand = new Random();
Microsoft.Extensions.Caching.MicroBenchmarks (1)
DistributedCacheBenchmarks.cs (1)
21private readonly Random random = new Random();
PresentationFramework (1)
System\Windows\Documents\FixedPageStructure.cs (1)
455Random random = new Random();
System.Text.RegularExpressions (3)
System\Text\RegularExpressions\Regex.Cache.cs (1)
57private static readonly Random s_random = new Random();
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.Sample.cs (2)
38Random random = randomseed != 0 ? new Random(randomseed) : new Random();
System.Text.RegularExpressions.Generator (1)
RegexGenerator.Emitter.cs (1)
1464Random stackCookieGenerator = new(12345); // seed for deterministic behavior
Wasm.Performance.TestApp (1)
Person.cs (1)
20var rng = new Random(0);
102 references to Random
BlazorServerApp (2)
Data\WeatherForecastService.cs (2)
18TemperatureC = Random.Shared.Next(-20, 55), 19Summary = Summaries[Random.Shared.Next(Summaries.Length)]
BlazorUnitedApp (2)
Data\WeatherForecastService.cs (2)
18TemperatureC = Random.Shared.Next(-20, 55), 19Summary = Summaries[Random.Shared.Next(Summaries.Length)]
HeaderPropagationSample (1)
Startup.cs (1)
113if (Random.Shared.NextDouble() > threshold)
HostedBlazorWebassemblyApp.Server (2)
Data\WeatherForecastService.cs (2)
24TemperatureC = Random.Shared.Next(-20, 55), 25Summary = Summaries[Random.Shared.Next(Summaries.Length)]
HttpStress (2)
Program.cs (2)
66seed: cmdline.ValueForOption<int?>("-seed") ?? Random.Shared.Next()); 632private readonly Random _random;
IIS.FunctionalTests (2)
src\Servers\IIS\IIS\test\Common.FunctionalTests\AspNetCorePortTests.cs (1)
159var port = Random.Shared.Next(_minPort, _maxPort);
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (1)
733var disconnectAfter = Random.Shared.Next(maxRequestSize);
IISExpress.FunctionalTests (2)
src\Servers\IIS\IIS\test\Common.FunctionalTests\AspNetCorePortTests.cs (1)
159var port = Random.Shared.Next(_minPort, _maxPort);
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (1)
733var disconnectAfter = Random.Shared.Next(maxRequestSize);
ILCompiler.DependencyAnalysisFramework (3)
DependencyAnalyzer.cs (3)
48private readonly Random _randomizer; 50public RandomInsertStack(Random randomizer = null) 107Random stackPopRandomizer = null;
InMemory.FunctionalTests (2)
src\Servers\Kestrel\shared\test\ServerRetryHelper.cs (2)
22var nextPortAttempt = 30000 + Random.Shared.Next(10000); 37nextPortAttempt = port + Random.Shared.Next(100);
Interop.FunctionalTests (2)
src\Servers\Kestrel\shared\test\ServerRetryHelper.cs (2)
22var nextPortAttempt = 30000 + Random.Shared.Next(10000); 37nextPortAttempt = port + Random.Shared.Next(100);
JwtClientSample (1)
Program.cs (1)
72nextMsgAt = Random.Shared.Next(2, 5);
KeyManagementSimulator (9)
Program.cs (9)
85seed = Random.Shared.Next(); 93var productRandom = new Random(seed); 94var simulatorRandom = new Random(productRandom.Next()); 326public AppInstance(int instanceNumber, IXmlEncryptor encryptor, IXmlDecryptor decryptor, IXmlRepository repository, Random productRandom) 471private readonly Random _random; 483public FlakyObject(Random random, double pFail) 520sealed class FlakyXmlRepository(Random random, double pFail) : FlakyObject(random, pFail), IXmlRepository 551sealed class FlakyXmlEncryptor(Random random, double pFail) : FlakyObject(random, pFail), IXmlEncryptor 570sealed class FlakyXmlDecryptor(Random random, double pFail) : FlakyObject(random, pFail), IXmlDecryptor
Microsoft.Arcade.Common (1)
ExponentialRetry.cs (1)
13private Random _random = new Random();
Microsoft.AspNetCore.Components.Server.Tests (2)
Circuits\RemoteJSDataStreamTest.cs (2)
52var random = new Random(); 80var random = new Random();
Microsoft.AspNetCore.DataProtection (2)
KeyManagement\KeyRingProvider.cs (2)
65JitterRandom = Random.Shared; 72internal Random JitterRandom { get; set; }
Microsoft.AspNetCore.Identity.Specification.Tests (2)
UserManagerSpecificationTests.cs (2)
304var email = "foo" + Random.Shared.Next() + "@example.com"; 305var newEmail = "bar" + Random.Shared.Next() + "@example.com";
Microsoft.AspNetCore.InternalTesting.Tests (2)
HttpClientSlimTest.cs (2)
72var random = Random.Shared;
Microsoft.AspNetCore.OpenApi.Tests (1)
Services\OpenApiComponentService\OpenApiComponentService.ResponseSchemas.cs (1)
101static Todo? GetTodo() => Random.Shared.Next() < 0.5 ? new Todo(1, "Test Title", true, DateTime.Now) : null;
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (7)
EndToEndBenchmarks.cs (7)
53Random.Shared.NextBytes(_payloadOversized); 80var rand = Random.Shared; 93var rand = Random.Shared; 108var rand = Random.Shared;
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (1)
RedisOutputCacheStore.cs (1)
98var secondsWithJitter = 300 + Random.Shared.Next(-30, 30);
Microsoft.AspNetCore.Routing.Tests (1)
RouteCollectionTest.cs (1)
508int index = Random.Shared.Next(0, routeNames.Length - 1);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (4)
KestrelServerTests.cs (2)
997? Random.Shared.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort) 1049? Random.Shared.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort)
src\Servers\Kestrel\shared\test\ServerRetryHelper.cs (2)
22var nextPortAttempt = 30000 + Random.Shared.Next(10000); 37nextPortAttempt = port + Random.Shared.Next(100);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (2)
src\Servers\Kestrel\shared\test\ServerRetryHelper.cs (2)
22var nextPortAttempt = 30000 + Random.Shared.Next(10000); 37nextPortAttempt = port + Random.Shared.Next(100);
Microsoft.AspNetCore.SignalR.Common.Tests (1)
Internal\Protocol\MemoryBufferWriterTests.cs (1)
406Random.Shared.NextBytes(data);
Microsoft.AspNetCore.SignalR.Microbenchmarks (2)
MessageParserBenchmark.cs (2)
25Random.Shared.NextBytes(buffer); 39Random.Shared.NextBytes(buffer);
Microsoft.AspNetCore.SignalR.Tests (1)
Internal\MessageBufferTests.cs (1)
254var ackNum = Random.Shared.Next(0, 1000);
Microsoft.AspNetCore.WebSockets.Tests (1)
WebSocketCompressionMiddlewareTests.cs (1)
146Random.Shared.NextBytes(clientBuf);
Microsoft.Build.Framework (1)
StringUtils.cs (1)
25Random random = new();
Microsoft.DotNet.Helix.Sdk (1)
AzureDevOpsTask.cs (1)
168private static readonly Random s_rand = new Random();
Microsoft.Extensions.Caching.Hybrid.Tests (3)
DistributedCacheTests.cs (3)
271var rand = new Random(); 345public CustomSegment(int size, Random? rand, CustomSegment? previous) 361public CustomMemory(int size, Random? rand = null)
Microsoft.Extensions.Caching.MicroBenchmarks (1)
DistributedCacheBenchmarks.cs (1)
21private readonly Random random = new Random();
Microsoft.Extensions.ObjectPool.Microbenchmark (1)
Foo.cs (1)
19LastRandom = Random.Shared.Next();
Microsoft.JSInterop.Tests (1)
JSRuntimeTest.cs (1)
339Random.Shared.NextBytes(byteArray);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
390[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Random))]
netstandard (1)
netstandard.cs (1)
1354[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Random))]
PresentationFramework (1)
System\Windows\Documents\FixedPageStructure.cs (1)
455Random random = new Random();
System.Collections.Concurrent (1)
System\Collections\Concurrent\ConcurrentStack.cs (1)
631backoff = Random.Shared.Next(1, BACKOFF_MAX_YIELDS);
System.Net.Ping (1)
System\Net\NetworkInformation\Ping.RawSocket.cs (1)
28ushort id = (ushort)Random.Shared.Next(ushort.MaxValue + 1);
System.Private.CoreLib (13)
src\libraries\System.Private.CoreLib\src\System\Random.cs (5)
28/// <summary>Initializes a new instance of the <see cref="Random"/> class using a default seed value.</summary> 33_impl = GetType() == typeof(Random) ? new XoshiroImpl() : new Net5CompatDerivedImpl(this); 44_impl = GetType() == typeof(Random) ? new Net5CompatSeedImpl(Seed) : new Net5CompatDerivedImpl(this, Seed); 54/// <summary>Provides a thread-safe <see cref="Random"/> instance that may be used concurrently from any thread.</summary> 55public static Random Shared { get; } = new ThreadSafeRandom();
src\libraries\System.Private.CoreLib\src\System\Random.Net5CompatImpl.cs (4)
109/// <summary>Reference to the <see cref="Random"/> containing this implementation instance.</summary> 111private readonly Random _parent; 117public Net5CompatDerivedImpl(Random parent) : this(parent, Shared.Next()) { } 119public Net5CompatDerivedImpl(Random parent, int seed)
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.HillClimbing.cs (2)
75private readonly Random.XoshiroImpl _randomIntervalGenerator = new Random.XoshiroImpl();
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (2)
1030public readonly Random.XoshiroImpl random = new Random.XoshiroImpl();
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net9.0\System.Runtime.Forwards.cs (1)
411[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Random))]
System.Runtime.Extensions (1)
System.Runtime.Extensions.cs (1)
26[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Random))]
System.Text.RegularExpressions (6)
System\Text\RegularExpressions\Regex.Cache.cs (1)
57private static readonly Random s_random = new Random();
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.Sample.cs (5)
38Random random = randomseed != 0 ? new Random(randomseed) : new Random(); 172static T Choose<T>(Random random, IList<T> elems) => elems[random.Next(elems.Count)]; 174static char ChooseChar(Random random, BDD bdd, BDD ascii, CharSetSolver charSetSolver) 183static bool FlipBiasedCoin(Random random, double probTrue) => random.NextDouble() < probTrue; 185static T[] Shuffle<T>(Random random, T[] array)
System.Text.RegularExpressions.Generator (1)
RegexGenerator.Emitter.cs (1)
1464Random stackCookieGenerator = new(12345); // seed for deterministic behavior
System.Threading.Tasks.Parallel (1)
System\Threading\Tasks\TaskReplicator.cs (1)
167return 100 + Random.Shared.Next(0, 50 * Environment.ProcessorCount);
Templates.Blazor.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
61private static char GetRandomLetter() => LetterChars[Random.Shared.Next(LetterChars.Length - 1)];
Templates.Blazor.WebAssembly.Auth.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
61private static char GetRandomLetter() => LetterChars[Random.Shared.Next(LetterChars.Length - 1)];
Templates.Blazor.WebAssembly.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
61private static char GetRandomLetter() => LetterChars[Random.Shared.Next(LetterChars.Length - 1)];
Templates.Mvc.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
61private static char GetRandomLetter() => LetterChars[Random.Shared.Next(LetterChars.Length - 1)];
Templates.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
61private static char GetRandomLetter() => LetterChars[Random.Shared.Next(LetterChars.Length - 1)];
Wasm.Performance.TestApp (1)
Person.cs (1)
20var rng = new Random(0);