Turn this into a record struct

This commit is contained in:
Brandon Thetford
2024-02-15 18:42:17 -07:00
parent 4e391e3017
commit 79997cea06

View File

@@ -11,7 +11,7 @@ namespace Terminal.Gui;
/// <see cref="ColorScheme"/> class to define color schemes that can be used in an application.
/// </remarks>
[JsonConverter (typeof (AttributeJsonConverter))]
public readonly struct Attribute : IEquatable<Attribute>, IEqualityOperators<Attribute, Attribute, bool>
public readonly record struct Attribute : IEqualityOperators<Attribute, Attribute, bool>
{
/// <summary>Default empty attribute.</summary>
public static readonly Attribute Default = new (Color.White, ColorName.Black);
@@ -107,21 +107,6 @@ public readonly struct Attribute : IEquatable<Attribute>, IEqualityOperators<Att
/// <param name="color">The color.</param>
public Attribute (in Color color) : this (color, color) { }
/// <summary>Compares two attributes for equality.</summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator == (Attribute left, Attribute right) { return left.Equals (right); }
/// <summary>Compares two attributes for inequality.</summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
public static bool operator != (Attribute left, Attribute right) { return !(left == right); }
/// <inheritdoc/>
public override bool Equals (object? obj) { return obj is Attribute other && Equals (other); }
/// <inheritdoc/>
public bool Equals (Attribute other) { return PlatformColor == other.PlatformColor && Foreground == other.Foreground && Background == other.Background; }