Use ArgumentOutOfRangeException.ThrowIfNegativeOrZero()

Proprietary

Replace if (value <= 0) throw new ArgumentOutOfRangeException(nameof(value)) guard clauses with ArgumentOutOfRangeException.ThrowIfNegativeOrZero(value). Also handles reversed 0 >= value. Available since .NET 7.

OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net7.UseThrowIfNegativeOrZero
mod run . --recipe=OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net7.UseThrowIfNegativeOrZero

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