using System; using System.Collections.Generic; using System.Collections.Immutable; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; namespace ComputeSharp.SourceGenerators.Models; /// /// A model representing gathered info on a shader dispatch id. /// /// The list of delegate field names for the shader. internal sealed record DispatchIdInfo(ImmutableArray Delegates) { /// public bool Equals(DispatchIdInfo? obj) => Comparer.Default.Equals(this, obj); /// public override int GetHashCode() => Comparer.Default.GetHashCode(this); /// /// An implementation for . /// private sealed class Comparer : Comparer { /// protected override void AddToHashCode(ref HashCode hashCode, DispatchIdInfo obj) { hashCode.AddRange(obj.Delegates); } /// protected override bool AreEqual(DispatchIdInfo x, DispatchIdInfo y) { return x.Delegates.SequenceEqual(y.Delegates); } } }