← All recipes
Moderne licensed

Convert HasFlag to bitwise operation

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Performance.ConvertHasFlagToBitwiseOperationArtifactOpenRewrite.Recipes.CSharp.CodeQuality

Replace flags.HasFlag(value) with (flags & value) != 0.

Single recipecsharpcode-qualityProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.CodeQuality.Performance.ConvertHasFlagToBitwiseOperation

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality