Skip to content

Commit

Permalink
Fix ThemeVariant equality (#17257)
Browse files Browse the repository at this point in the history
* Added failing ThemeVariant theme

* Fixed ThemeVariant.Equals
  • Loading branch information
MrJul authored and maxkatz6 committed Oct 27, 2024
1 parent d41d5bb commit f965634
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Styling/ThemeVariant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override int GetHashCode()

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public void DynamicResource_Updated_When_Control_Theme_Changed()

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);
}
Expand Down

0 comments on commit f965634

Please sign in to comment.