Convert a dependency property to a read-only dependency property

Proprietary

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

OpenRewrite.Recipes.CSharp.CodeQuality.Wpf.ConvertDependencyPropertyToReadOnly
mod run . --recipe=OpenRewrite.Recipes.CSharp.CodeQuality.Wpf.ConvertDependencyPropertyToReadOnly

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