WPF code quality

Proprietary

Correctness rules for WPF dependency properties, routed events, routed commands, value converters, markup extensions, template parts, styles and XML documentation, ported from the WpfAnalyzers Roslyn analyzers.

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

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

Recipe list

It runs these recipes, in this order.

  1. Backing member for a DependencyProperty should match registered name
  2. Backing member for a DependencyPropertyKey should match registered name
  3. CLR property for a DependencyProperty should match registered name
  4. CLR method for a DependencyProperty must match registered name
  5. Convert a trivial dependency property callback to a lambda
  6. Name the PropertyChangedCallback OnNameChanged
  7. Name the CoerceValueCallback CoerceName
  8. Name the ValidateValueCallback ValidateName
  9. Target of [DependsOn] should exist
  10. Default value type must match registered type
  11. Containing type should be used as registered owner
  12. CLR property type should match registered type
  13. CLR accessor for attached property must match registered type
  14. SetValue must use the registered type
  15. Registered owner type must inherit DependencyObject
  16. Default value is a shared reference type
  17. Metadata must be of the same type or a super type
  18. Use containing type
  19. Cast the sender of a dependency property callback to the correct type
  20. Cast the value of a dependency property callback to the correct type
  21. Cast the sender of a dependency property callback to the containing type
  22. Cast the value of a dependency property callback to the exact type
  23. Declare the coerce and validate callback value parameter nullable
  24. Backing member for a DependencyProperty should be static and readonly
  25. DependencyPropertyKey member must be declared before DependencyProperty member
  26. Use same dependency property in get and set
  27. Add [AttachedPropertyBrowsableForType]
  28. Use correct argument for [AttachedPropertyBrowsableForType]
  29. Use SetValue in setter
  30. Avoid side effects in CLR accessors
  31. Set a readonly DependencyProperty using its DependencyPropertyKey
  32. Set a mutable dependency property using SetCurrentValue
  33. Avoid side effects in attached property CLR accessors
  34. Do not set DataContext or Style using SetCurrentValue
  35. XmlnsPrefix must map to the same url as XmlnsDefinition
  36. XmlnsDefinition must map to an existing namespace
  37. XmlnsDefinitions should map all namespaces with public types
  38. Backing member for DependencyProperty should have standard documentation text
  39. Accessor method for attached property should have standard documentation text
  40. Property changed callback should have standard documentation text
  41. Add default field to converter
  42. Add ValueConversion attribute
  43. ValueConversion must use correct types
  44. Add ValueConversion attribute (unknown types)
  45. Use containing type
  46. Add MarkupExtensionReturnType attribute
  47. MarkupExtensionReturnType must use correct return type
  48. [ConstructorArgument] must match
  49. Add [ConstructorArgument]
  50. Target of [XamlSetMarkupExtension] should exist and have correct signature
  51. Target of [XamlSetTypeConverter] should exist and have correct signature
  52. Name the RegisterClassHandler callback OnEventName
  53. Name the AddHandler/RemoveHandler callback OnEventName
  54. Use the registered routed event handler type
  55. Backing member for a RoutedEvent should match registered name
  56. Containing type should be used as registered owner
  57. Name of the event should match registered name
  58. Use same event in add and remove
  59. Call AddHandler in add
  60. Call RemoveHandler in remove
  61. Use the registered handler type
  62. Backing member for a RoutedEvent should be static and readonly
  63. Backing member for RoutedEvent should have standard documentation text
  64. Register the containing member as the name for a RoutedCommand
  65. Register the containing type as the owner for a RoutedCommand
  66. Register a name and an owning type for a RoutedCommand
  67. Backing member for a RoutedCommand should be static and readonly
  68. Add [TemplatePart] for a looked-up template part
  69. Use the declared [TemplatePart] type
  70. Use the PART_ prefix for template part names
  71. ContentProperty should name an existing property
  72. Use the containing type when creating a ComponentResourceKey
  73. Use the containing member as the key when creating a ComponentResourceKey
  74. Use nameof() instead of a string literal
  75. Use nameof() instead of a constant
  76. StyleTypedProperty.Property must exist
  77. StyleTypedProperty.Property should name a Style property
  78. StyleTypedProperty.Property should be specified
  79. StyleTypedProperty.StyleTargetType should support styling
  80. StyleTypedProperty.StyleTargetType should be specified
  81. StyleTypedProperty.Property should be specified only once
  82. StyleTypedProperty should be specified for a Style property