Use ArgumentNullException.ThrowIfNull()

Proprietary

Replace if (x == null) throw new ArgumentNullException(nameof(x)) guard clauses with ArgumentNullException.ThrowIfNull(x) (CA1510). Handles == null, is null, reversed null ==, string literal param names, and braced then-blocks. Available since .NET 6.

OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseThrowIfNull
mod run . --recipe=OpenRewrite.Recipes.CSharp.Migration.Dotnet.Net6.UseThrowIfNull

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