Use span construction for guarded nonempty string copies
ProprietaryReplace bound String.Copy(parameter) with a fresh string constructed from its span after a first-statement String.IsNullOrEmpty(parameter) return guard or a top-level !File.Exists(parameter) return guard. Require a by-value string parameter with no writes, ref escapes or nested executable contexts. Preserve nonempty content and fresh identity without an intermediate array. Leave arbitrary/empty inputs, named arguments, generic declarations, snapshots and selector comments unchanged. Opt-in migration for .NET Core 3.0 or later; do not remove identity-sensitive copies.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseSpanForGuardedStringCopymod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseSpanForGuardedStringCopyInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.