An efficient thread-safe randomizer that can optionally be used as a source generator.
The recommended means is to use NuGet, but you could also download the source code from here.
Replace:
var random = new Random();
var myNum = random.Next();With:
var myNum = ThreadSafeRandom.Instance.Next();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.0" /> to:
<PackageReference Include="ThreadSafeRandomizer" Version="3.0.0">
<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.
