Skip to content

Commit 28ae0a8

Browse files
committed
No repro for #354
1 parent ca5ab75 commit 28ae0a8

3 files changed

Lines changed: 48 additions & 5 deletions

File tree

ValidCode/Repro/Issue354.TypeA.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace ValidCode.Repro
2+
{
3+
using System.Windows;
4+
using System.Windows.Controls;
5+
using System.Windows.Media;
6+
7+
public class TypeA : Image
8+
{
9+
public Geometry? IconGeometry
10+
{
11+
get => (Geometry?)GetValue(IconGeometryProperty);
12+
set => SetValue(IconGeometryProperty, value);
13+
}
14+
15+
/// <summary>Identifies the <see cref="IconGeometry"/> dependency property.</summary>
16+
public static readonly DependencyProperty IconGeometryProperty =
17+
DependencyProperty.Register(nameof(IconGeometry), typeof(Geometry), typeof(TypeA), new PropertyMetadata(null));
18+
}
19+
}

ValidCode/Repro/Issue354.TypeB.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace ValidCode.Repro
2+
{
3+
using System.Windows;
4+
using System.Windows.Controls;
5+
using System.Windows.Media;
6+
7+
public class TypeB : Image
8+
{
9+
public Geometry? IconGeometry
10+
{
11+
get => (Geometry?)GetValue(IconGeometryProperty);
12+
// WPF0014 SetValue must use registered type System.Windows.Media.Geometry
13+
set => SetValue(IconGeometryProperty, value);
14+
}
15+
16+
/// <summary>Identifies the <see cref="IconGeometry"/> dependency property.</summary>
17+
public static readonly DependencyProperty IconGeometryProperty =
18+
// WPF0010 Default value for 'TypeA.IconGeometryProperty' must be of type System.Windows.Media.Geometry
19+
#pragma warning disable WPF0016 // Default value is shared reference type
20+
TypeA.IconGeometryProperty.AddOwner(typeof(TypeB), new FrameworkPropertyMetadata(new EllipseGeometry(default, 5, 5)));
21+
#pragma warning restore WPF0016 // Default value is shared reference type
22+
}
23+
}

WpfAnalyzers.Test/ValidWithAll.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
public static class ValidWithAll
1313
{
14-
private static readonly IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers = typeof(KnownSymbols)
15-
.Assembly.GetTypes()
16-
.Where(x => typeof(DiagnosticAnalyzer).IsAssignableFrom(x) && !x.IsAbstract)
17-
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t))
18-
.ToArray();
14+
private static readonly IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers =
15+
typeof(KnownSymbols)
16+
.Assembly.GetTypes()
17+
.Where(x => typeof(DiagnosticAnalyzer).IsAssignableFrom(x) && !x.IsAbstract)
18+
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t))
19+
.ToArray();
1920

2021
private static readonly Solution AnalyzerProjectSolution = CodeFactory.CreateSolution(
2122
ProjectFile.Find("WpfAnalyzers.csproj"));

0 commit comments

Comments
 (0)