Convert a dependency property to a read-only dependency property
Recipe ID
OpenRewrite.Recipes.CSharp.CodeQuality.Wpf.ConvertDependencyPropertyToReadOnlyArtifactOpenRewrite.Recipes.CSharp.CodeQualityRewrites DependencyProperty.Register to RegisterReadOnly, holding the result in a private DependencyPropertyKey and exposing <key>.DependencyProperty under the original name. Every SetValue on the property inside the declaring type is moved onto the key, which is the only way a read-only dependency property can be written.
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.ConvertDependencyPropertyToReadOnlyIf the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality