Use ArgumentOutOfRangeException.ThrowIfGreaterThan()

Proprietary

Replace if (value > other) throw new ArgumentOutOfRangeException(nameof(value)) guard clauses with ArgumentOutOfRangeException.ThrowIfGreaterThan(value, other). Also handles reversed other < value and >=/ThrowIfGreaterThanOrEqual. Available since .NET 8.

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

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