// 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. // This file is ported and adapted from ComputeSharp (Sergio0694/ComputeSharp), // more info in ThirdPartyNotices.txt in the root of the project. using System; using System.Collections.Generic; using System.Collections.Immutable; namespace CommunityToolkit.Mvvm.SourceGenerators.Extensions; /// /// Extension methods for . /// internal static class HashCodeExtensions { /// /// Adds all items from a given instance to an hashcode. /// /// The type of items to hash. /// The target instance. /// The input items to hash. public static void AddRange(this ref HashCode hashCode, ImmutableArray items) { foreach (T item in items) { hashCode.Add(item); } } /// /// Adds all items from a given instance to an hashcode. /// /// The type of items to hash. /// The target instance. /// A comparer to get hashcodes for items. /// The input items to hash. public static void AddRange(this ref HashCode hashCode, ImmutableArray items, IEqualityComparer comparer) { foreach (T item in items) { hashCode.Add(item, comparer); } } }