Use ArgumentOutOfRangeException.ThrowIfNegative()
ProprietaryReplace if (value < 0) throw new ArgumentOutOfRangeException(nameof(value)) guard clauses with ArgumentOutOfRangeException.ThrowIfNegative(value). Also handles reversed 0 > value. Available since .NET 7.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net7. UseThrowIfNegativemod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net7. UseThrowIfNegativeInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.