Skip to content

Commit f965634

Browse files
MrJulmaxkatz6
authored andcommitted
Fix ThemeVariant equality (#17257)
* Added failing ThemeVariant theme * Fixed ThemeVariant.Equals
1 parent d41d5bb commit f965634

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Avalonia.Base/Styling/ThemeVariant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public override int GetHashCode()
9191

9292
public bool Equals(ThemeVariant? other)
9393
{
94-
return Key == other?.Key;
94+
return other is not null && Equals(Key, other.Key);
9595
}
9696

9797
public static explicit operator ThemeVariant(PlatformThemeVariant themeVariant)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public void DynamicResource_Updated_When_Control_Theme_Changed()
4545

4646
Assert.Equal(Colors.White, ((ISolidColorBrush)border.Background)!.Color);
4747

48-
themeVariantScope.RequestedThemeVariant = ThemeVariant.Dark;
48+
var themeVariantKey = new string(['D', 'a', 'r', 'k']); // Ensure that a non-interned string works
49+
themeVariantScope.RequestedThemeVariant = new ThemeVariant(themeVariantKey, null);
4950

5051
Assert.Equal(Colors.Black, ((ISolidColorBrush)border.Background)!.Color);
5152
}

0 commit comments

Comments
 (0)