← All recipes
Moderne licensed

Use nameof() instead of a string literal

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Wpf.UseNameofInsteadOfLiteralArtifactOpenRewrite.Recipes.CSharp.CodeQuality

Registering a DependencyProperty, RoutedEvent or RoutedCommand with a string literal silently breaks when the corresponding member is renamed. Replaces the literal with nameof(...) when a member of that name exists on the containing type.

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.Wpf.UseNameofInsteadOfLiteral

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

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