Skip to content

Commit 9b82d4e

Browse files
committed
Test that we warn for freezable when the registered type is not
1 parent 28ae0a8 commit 9b82d4e

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

  • WpfAnalyzers.Test/WPF0010DefaultValueMustMatchRegisteredTypeTests

WpfAnalyzers.Test/WPF0010DefaultValueMustMatchRegisteredTypeTests/Diagnostics.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,40 @@ static BarControl()
273273
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic, fooControlCode, code);
274274
}
275275

276+
[Test]
277+
public static void FrozenGeometry()
278+
{
279+
var code = @"
280+
namespace N
281+
{
282+
using System.Windows;
283+
using System.Windows.Controls;
284+
using System.Windows.Media;
285+
286+
public class C : Control
287+
{
288+
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
289+
nameof(Text),
290+
typeof(string),
291+
typeof(C),
292+
new PropertyMetadata(↓Default()));
293+
294+
public string? Text
295+
{
296+
get => (string?)this.GetValue(TextProperty);
297+
set => this.SetValue(TextProperty, value);
298+
}
299+
300+
private static Freezable Default()
301+
{
302+
var geometry = new EllipseGeometry(default, 5, 5);
303+
return geometry.GetAsFrozen();
304+
}
305+
}
306+
}";
307+
RoslynAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
308+
}
309+
276310
[Test]
277311
public static void IntWhenTypeIsEnum()
278312
{

0 commit comments

Comments
 (0)