Use static random fill for a fresh array and closed provider
ProprietaryReplace a sole GetBytes(byte[]) call in a parameterless RNGCryptoServiceProvider using statement immediately after a fresh byte[] local allocation with RandomNumberGenerator.Fill. Retain the original array/allocation, buffer identity and surrounding code. Skip nonzero/ranged fills, unknown or shared buffers, other providers/factories, comments, initializers, captures/ref/unsafe/async and conditional snapshots. Opt-in modern-.NET port; no seed, algorithm or key policy is selected.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net6. UseClosedFreshArrayRandomFillmod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net6. UseClosedFreshArrayRandomFillInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.