Browse Source

Fix ThemeVariant equality (#17257)

* Added failing ThemeVariant theme

* Fixed ThemeVariant.Equals
pull/17251/head
Julien Lebosquain 1 year ago
committed by GitHub
parent
commit
a04af7cebf
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/Avalonia.Base/Styling/ThemeVariant.cs
  2. 3
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ThemeDictionariesTests.cs

2
src/Avalonia.Base/Styling/ThemeVariant.cs

@ -91,7 +91,7 @@ public sealed record ThemeVariant
public bool Equals(ThemeVariant? other)
{
return Key == other?.Key;
return other is not null && Equals(Key, other.Key);
}
public static explicit operator ThemeVariant(PlatformThemeVariant themeVariant)

3
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ThemeDictionariesTests.cs

@ -45,7 +45,8 @@ public class ThemeDictionariesTests : XamlTestBase
Assert.Equal(Colors.White, ((ISolidColorBrush)border.Background)!.Color);
themeVariantScope.RequestedThemeVariant = ThemeVariant.Dark;
var themeVariantKey = new string(['D', 'a', 'r', 'k']); // Ensure that a non-interned string works
themeVariantScope.RequestedThemeVariant = new ThemeVariant(themeVariantKey, null);
Assert.Equal(Colors.Black, ((ISolidColorBrush)border.Background)!.Color);
}

Loading…
Cancel
Save