Use static random fill for a fresh array and closed using declaration

Proprietary

Replace a sole GetBytes(byte[]) call immediately after an adjacent parameterless BCL RNGCryptoServiceProvider using declaration and fresh byte[] local allocation (either declaration order) with typed RandomNumberGenerator.Fill. Retain the original allocation and following consumers; require no other provider reference in the block. Skip unknown/shared buffers, other factories/providers, nonzero/ranged/multiple fills, comments, captures/ref/unsafe/async and conditional snapshots. Opt-in modern API port; no algorithm, size, seed or ownership policy change.

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

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