From 0eb5da5fd4bc9657f441a439fb85bf0a2be7cd61 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 5 Apr 2026 01:59:34 -0400 Subject: [PATCH] Default sort is never done, so CompareTo is useless --- .../DatItemTests.cs | 60 ------------------- SabreTools.Metadata.DatItems/DatItem.cs | 22 +------ SabreTools.Metadata.DatItems/DatItemT.cs | 22 +------ 3 files changed, 2 insertions(+), 102 deletions(-) diff --git a/SabreTools.Metadata.DatItems.Test/DatItemTests.cs b/SabreTools.Metadata.DatItems.Test/DatItemTests.cs index e81048fe..d0db98e5 100644 --- a/SabreTools.Metadata.DatItems.Test/DatItemTests.cs +++ b/SabreTools.Metadata.DatItems.Test/DatItemTests.cs @@ -194,66 +194,6 @@ namespace SabreTools.Metadata.DatItems.Test #endregion - #region CompareTo - - [Fact] - public void CompareTo_NullOther_Returns1() - { - DatItem self = new Rom(); - DatItem? other = null; - - int actual = self.CompareTo(other); - Assert.Equal(1, actual); - } - - [Fact] - public void CompareTo_DifferentOther_Returns1() - { - DatItem self = new Rom { Name = "name" }; - - DatItem? other = new Disk { Name = "name" }; - - int actual = self.CompareTo(other); - Assert.Equal(1, actual); - } - - [Fact] - public void CompareTo_Empty_Returns1() - { - DatItem self = new Rom(); - DatItem? other = new Rom(); - - int actual = self.CompareTo(other); - Assert.Equal(1, actual); - } - - [Theory] - [InlineData(null, null, 0)] - [InlineData("name", null, 1)] - [InlineData("name", "other", -1)] - [InlineData(null, "name", -1)] - [InlineData("other", "name", 1)] - [InlineData("name", "name", 0)] - public void CompareTo_NamesOnly(string? selfName, string? otherName, int expected) - { - DatItem self = new Rom - { - Name = selfName, - CRC = "DEADBEEF" - }; - - DatItem? other = new Rom - { - Name = otherName, - CRC = "DEADBEEF" - }; - - int actual = self.CompareTo(other); - Assert.Equal(expected, actual); - } - - #endregion - #region Equals [Fact] diff --git a/SabreTools.Metadata.DatItems/DatItem.cs b/SabreTools.Metadata.DatItems/DatItem.cs index b64e7b36..786515ee 100644 --- a/SabreTools.Metadata.DatItems/DatItem.cs +++ b/SabreTools.Metadata.DatItems/DatItem.cs @@ -52,7 +52,7 @@ namespace SabreTools.Metadata.DatItems [XmlInclude(typeof(SoftwareList))] [XmlInclude(typeof(Sound))] [XmlInclude(typeof(SourceDetails))] - public abstract class DatItem : ICloneable, IComparable, IEquatable + public abstract class DatItem : ICloneable, IEquatable { #region Properties @@ -137,26 +137,6 @@ namespace SabreTools.Metadata.DatItems #region Comparision Methods - /// - public int CompareTo(DatItem? other) - { - // If the other item doesn't exist - if (other is null) - return 1; - - // Get the names to avoid changing values - string? selfName = GetName(); - string? otherName = other.GetName(); - - // If the names are equal - if (selfName == otherName) - return Equals(other) ? 0 : 1; - - // If `otherName` is null, Compare will return > 0 - // If `selfName` is null, Compare will return < 0 - return string.Compare(selfName, otherName, StringComparison.Ordinal); - } - /// /// Determine if an item is a duplicate using partial matching logic /// diff --git a/SabreTools.Metadata.DatItems/DatItemT.cs b/SabreTools.Metadata.DatItems/DatItemT.cs index dc34727a..1f7b50ed 100644 --- a/SabreTools.Metadata.DatItems/DatItemT.cs +++ b/SabreTools.Metadata.DatItems/DatItemT.cs @@ -6,7 +6,7 @@ namespace SabreTools.Metadata.DatItems /// /// Base class for all items included in a set that are backed by an internal model /// - public abstract class DatItem : DatItem, IEquatable>, IComparable>, ICloneable + public abstract class DatItem : DatItem, ICloneable, IEquatable> where T : Data.Models.Metadata.DatItem, new() { #region Private Fields @@ -54,26 +54,6 @@ namespace SabreTools.Metadata.DatItems #region Comparision Methods - /// - public int CompareTo(DatItem? other) - { - // If the other item doesn't exist - if (other is null) - return 1; - - // Get the names to avoid changing values - string? selfName = GetName(); - string? otherName = other.GetName(); - - // If the names are equal - if (selfName == otherName) - return Equals(other) ? 0 : 1; - - // If `otherName` is null, Compare will return > 0 - // If `selfName` is null, Compare will return < 0 - return string.Compare(selfName, otherName, StringComparison.Ordinal); - } - /// /// Determine if an item is a duplicate using partial matching logic ///