Use the default RNG factory for a local used once

Proprietary

Replace a parameterless RNGCryptoServiceProvider local immediately used for one byte-array GetBytes/GetNonZeroBytes call with RandomNumberGenerator.Create().GetBytes/GetNonZeroBytes. Modern .NET's provider constructor creates that same generator and forwards these calls. Require the local to have no other uses. Preserve argument evaluation, null failures and fill behavior. Provider arguments, escaping/reused locals, disposal scopes, other overloads and conditional snapshots remain unchanged.

OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseImmediateRandomNumberGenerator
mod run . --recipe=OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseImmediateRandomNumberGenerator

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.