Files
codeql/csharp/ql/test/query-tests/Likely Bugs/RandomUsedOnce/RandomUsedOnce.cs
2026-07-07 14:09:48 +01:00

23 lines
511 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
class RandomTest
{
void f()
{
new Random().Next(); // $ Alert // BAD
byte[] buffer = new byte[10];
new Random().NextBytes(buffer); // $ Alert // BAD
new Random().NextDouble(); // $ Alert // BAD
new Random().Next(10); // $ Alert // BAD
new Random().Next(10, 20); // $ Alert // BAD
new Random().Equals(null); // GOOD
}
}