Browse Source
Fix ThemeVariant equality (#17257)
* Added failing ThemeVariant theme
* Fixed ThemeVariant.Equals
pull/17251/head
Julien Lebosquain
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
3 additions and
2 deletions
-
src/Avalonia.Base/Styling/ThemeVariant.cs
-
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ThemeDictionariesTests.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) |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
|