From 76da6543520d14aa5b0a49d066e19d2acb364b1d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 20 Oct 2022 03:25:02 +0200 Subject: [PATCH] Remove Comparer type --- .../ComputeSharp.SourceGeneration.projitems | 1 - .../Helpers/Comparer{T,TSelf}.cs | 68 ------------------- 2 files changed, 69 deletions(-) delete mode 100644 src/ComputeSharp.SourceGeneration/Helpers/Comparer{T,TSelf}.cs diff --git a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems index 6a4c84ab..6a561e17 100644 --- a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems +++ b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems @@ -17,7 +17,6 @@ - diff --git a/src/ComputeSharp.SourceGeneration/Helpers/Comparer{T,TSelf}.cs b/src/ComputeSharp.SourceGeneration/Helpers/Comparer{T,TSelf}.cs deleted file mode 100644 index 000ccd39..00000000 --- a/src/ComputeSharp.SourceGeneration/Helpers/Comparer{T,TSelf}.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace ComputeSharp.SourceGeneration.Helpers; - -/// -/// A base implementation for instances. -/// -/// The type of items to compare. -/// The concrete comparer type. -internal abstract class Comparer : IEqualityComparer - where TSelf : Comparer, new() -{ - /// - /// The singleton instance. - /// - public static TSelf Default { get; } = new(); - - /// - public bool Equals(T? x, T? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return AreEqual(x, y); - } - - /// - public int GetHashCode(T obj) - { - HashCode hashCode = default; - - AddToHashCode(ref hashCode, obj); - - return hashCode.ToHashCode(); - } - - /// - /// Adds the current instance to an incremental value. - /// - /// The target value. - /// The instance being inspected. - protected abstract void AddToHashCode(ref HashCode hashCode, T obj); - - /// - /// Compares two instances for equality. - /// - /// The first instance to compare. - /// The second instance to compare. - /// Whether or not and are equal. - protected abstract bool AreEqual(T x, T y); -} \ No newline at end of file