Use ArgumentOutOfRangeException.ThrowIfZero()

Proprietary

Replace if (value == 0) throw new ArgumentOutOfRangeException(nameof(value)) guard clauses with ArgumentOutOfRangeException.ThrowIfZero(value). Also handles reversed 0 == value. Available since .NET 8.

OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net8.UseThrowIfZero
mod run . --recipe=OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net8.UseThrowIfZero

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