using System; using System.Collections.Generic; using System.Collections.Immutable; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; namespace ComputeSharp.Core.SourceGenerators.Models; /// /// A model containiing information on a constructor to generate. /// /// The values for the constructor. /// The names of ignored fields that should be defaulted. internal sealed record ConstructorInfo(ImmutableArray Parameters, ImmutableArray DefaultedFields) { /// public bool Equals(ConstructorInfo? 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, ConstructorInfo obj) { hashCode.AddRange(obj.Parameters); hashCode.AddRange(obj.DefaultedFields); } /// protected override bool AreEqual(ConstructorInfo x, ConstructorInfo y) { return x.Parameters.SequenceEqual(y.Parameters) && x.DefaultedFields.SequenceEqual(y.DefaultedFields); } } }