<commit_before># WPF0002
## Backing field for a DependencyPropertyKey should match registered name.

<!-- start generated table -->
<table>
<tr>
  <td>CheckId</td>
  <td>WPF0002</td>
</tr>
<tr>
  <td>Severity</td>
  <td>Warning</td>
</tr>
<tr>
  <td>Category</td>
  <td>WpfAnalyzers.DependencyProperties</td>
</tr>
<tr>
  <td>TypeName</td>
  <td><a href="https://github.com/DotNetAnalyzers/WpfAnalyzers/blob/master/WpfAnalyzers.Analyzers/DependencyProperties/WPF0002BackingFieldForDependencyPropertyKeyShouldMatchRegisteredName.cs">WPF0002BackingFieldForDependencyPropertyKeyShouldMatchRegisteredName</a></td>
</tr>
</table>
<!-- end generated table -->

## Description

A DependencyPropertyKey's backing field must be named with the name it is registered with suffixed by 'PropertyKey'

## Motivation

This is the most common convention and is used in the WPF framework.

In the following example, the backing DependencyPropertyKey field for the Title dependency property is named HighlightBrush. It should instead be named TitlePropertyKey.
It is legal to have it like this but will be a confusing API.

```C#
using System.Windows;

public class MyControl : FrameworkElement
{
    private static readonly DependencyPropertyKey HighlightBrush = DependencyProperty.RegisterReadOnly(
        "Title",
        typeof(string),
        typeof(MyControl),
        new PropertyMetadata(default(string)));

    public static readonly DependencyProperty TitleProperty = HighlightBrush.DependencyProperty;

    public string Title
    {
        get { return (string)this.GetValue(TitleProperty); }
        protected set { this.SetValue(HighlightBrush, value); }
    }
}
```

## How to fix violations

Name the backing field like this:

```C#
using System.Windows;

public class MyControl : FrameworkElement
{
    private static readonly DependencyPropertyKey TitlePropertyKey = DependencyProperty.RegisterReadOnly(
        "Title",
        typeof(string),
        typeof(MyControl),
        new PropertyMetadata(default(string)));

    public static readonly DependencyProperty TitleProperty = TitlePropertyKey.DependencyProperty;

    public string Title
    {<commit_msg>Amend, use nameof as Sam suggetsed.<commit_after># WPF0002
## Backing field for a DependencyPropertyKey should match registered name.

<!-- start generated table -->
<table>
<tr>
  <td>CheckId</td>
  <td>WPF0002</td>
</tr>
<tr>
  <td>Severity</td>
  <td>Warning</td>
</tr>
<tr>
  <td>Category</td>
  <td>WpfAnalyzers.DependencyProperties</td>
</tr>
<tr>
  <td>TypeName</td>
  <td><a href="https://github.com/DotNetAnalyzers/WpfAnalyzers/blob/master/WpfAnalyzers.Analyzers/DependencyProperties/WPF0002BackingFieldForDependencyPropertyKeyShouldMatchRegisteredName.cs">WPF0002BackingFieldForDependencyPropertyKeyShouldMatchRegisteredName</a></td>
</tr>
</table>
<!-- end generated table -->

## Description

A DependencyPropertyKey's backing field must be named with the name it is registered with suffixed by 'PropertyKey'

## Motivation

This is the most common convention and is used in the WPF framework.

In the following example, the backing DependencyPropertyKey field for the Title dependency property is named HighlightBrush. It should instead be named TitlePropertyKey.
It is legal to have it like this but will be a confusing API.

```C#
using System.Windows;

public class MyControl : FrameworkElement
{
    private static readonly DependencyPropertyKey HighlightBrush = DependencyProperty.RegisterReadOnly(
        nameof(Title),
        typeof(string),
        typeof(MyControl),
        new PropertyMetadata(default(string)));

    public static readonly DependencyProperty TitleProperty = HighlightBrush.DependencyProperty;

    public string Title
    {
        get { return (string)this.GetValue(TitleProperty); }
        protected set { this.SetValue(HighlightBrush, value); }
    }
}
```

## How to fix violations

Name the backing field like this:

```C#
using System.Windows;

public class MyControl : FrameworkElement
{
    private static readonly DependencyPropertyKey TitlePropertyKey = DependencyProperty.RegisterReadOnly(
        nameof(Title),
        typeof(string),
        typeof(MyControl),
        new PropertyMetadata(default(string)));

    public static readonly DependencyProperty TitleProperty = TitlePropertyKey.DependencyProperty;

    public string Title
    {
{'fraction_non_alphanumeric': 0.09353507565337002, 'fraction_numerical': 0.007336084364970197, 'mean_word_length': 4.474278544542033, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5490491', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1196, 'n_words': 355}