← All recipes
Moderne licensed

Convert an auto-property to a dependency property

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Wpf.ConvertAutoPropertyToDependencyPropertyArtifactOpenRewrite.Recipes.CSharp.CodeQuality

An auto-property on a DependencyObject cannot be bound, styled or animated. Registers a DependencyProperty for it and rewrites the property to get => (T)GetValue(XProperty); / set => SetValue(XProperty, value);, keeping any initializer as the metadata default. A setter that is not public — or a get-only property — produces the read-only DependencyPropertyKey pattern instead.

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.ConvertAutoPropertyToDependencyProperty

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

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