diff --git a/WpfAnalyzers.Test/WPF0019CastSenderToCorrectTypeTests/CodeFix.cs b/WpfAnalyzers.Test/WPF0019CastSenderToCorrectTypeTests/CodeFix.cs index 6a565102..1f985ffb 100644 --- a/WpfAnalyzers.Test/WPF0019CastSenderToCorrectTypeTests/CodeFix.cs +++ b/WpfAnalyzers.Test/WPF0019CastSenderToCorrectTypeTests/CodeFix.cs @@ -310,118 +310,6 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); } - [Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")] - [Test] - public void DependencyPropertyRegisterAttached() - { - var testCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(1, OnValueChanged)); - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - - var fixedCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(1, OnBarChanged)); - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); - } - - [Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")] - [Test] - public void DependencyPropertyRegisterAttachedReadOnly() - { - var testCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(default(int), OnValueChanged)); - - public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty; - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - - var fixedCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(default(int), OnBarChanged)); - - public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty; - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); - } - [Test] public void DependencyPropertyOverrideMetadata() { diff --git a/WpfAnalyzers.Test/WPF0021DirectCastSenderToExactTypeTests/CodeFix.cs b/WpfAnalyzers.Test/WPF0021DirectCastSenderToExactTypeTests/CodeFix.cs index dd8990d2..bbc34961 100644 --- a/WpfAnalyzers.Test/WPF0021DirectCastSenderToExactTypeTests/CodeFix.cs +++ b/WpfAnalyzers.Test/WPF0021DirectCastSenderToExactTypeTests/CodeFix.cs @@ -306,118 +306,6 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); } - [Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")] - [Test] - public void DependencyPropertyRegisterAttached() - { - var testCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(1, OnBarChanged)); - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - - var fixedCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - public static readonly DependencyProperty BarProperty = DependencyProperty.RegisterAttached( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(1, OnBarChanged)); - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarProperty, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (FrameworkElement)d; - } - } -}"; - AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); - } - - [Explicit("Not handling this yet, will be a bit messy as we need to get the type from the arguments in the getvalue & setvalue methods and can still not be sure. Perhaps limited value?.")] - [Test] - public void DependencyPropertyRegisterAttachedReadOnly() - { - var testCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(default(int), OnBarChanged)); - - public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty; - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (↓DataGrid)d; - } - } -}"; - - var fixedCode = @" -namespace RoslynSandbox -{ - using System.Windows; - - public static class Foo - { - private static readonly DependencyPropertyKey BarPropertyKey = DependencyProperty.RegisterAttachedReadOnly( - ""Bar"", - typeof(int), - typeof(Foo), - new PropertyMetadata(default(int), OnBarChanged)); - - public static readonly DependencyProperty BarProperty = BarPropertyKey.DependencyProperty; - - public static void SetBar(this FrameworkElement element, int value) => element.SetValue(BarPropertyKey, value); - - public static int GetBar(this FrameworkElement element) => (int)element.GetValue(BarProperty); - - private static void OnBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (FrameworkElement)d; - } - } -}"; - AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, testCode, fixedCode); - } - [Test] public void DependencyPropertyOverrideMetadata() {