ThreadSafeRandomizer
v3.0.1Latest Stable
net6.0net7.0.NETStandard1.0.NETStandard2.0
An efficient thread-safe randomizer that can optionally be used as a source generator.
Published
Nov 15, 2026
8d ago
Total Downloads
21.5K
21,472
Install
dotnet add package ThreadSafeRandomizer --version 3.0.1
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
ThreadSafeRandomizer
An efficient thread-safe randomizer that can optionally be used as a source generator.
Installation
The recommended means is to use NuGet, but you could also download the source code from here.
Usage
Replace:
var random = new Random();
var myNum = random.Next();
With:
var myNum = ThreadSafeRandom.Instance.Next();
Source Generator
The usage as a source generator is almost identical to using it as a dependency. The main difference is changing:
<PackageReference Include="ThreadSafeRandomizer" Version="3.0.1" />
to:
<PackageReference Include="ThreadSafeRandomizer" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>analyzers</IncludeAssets>
</PackageReference>
However, please note that the source generated file will purposely be internal rather than public to avoid conflicts.
Changes from Previous Version
No structural changes between v3.0.0 and v3.0.1.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.