/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/Test/Core/SourceGeneration/LambdaComparer.cs
26 строк
876 B
Chris Sienkiewicz
State Table Cleanup (#53383)
19 май 2021, 02:11
Не верифицирован
19 май 2021, 02:11
8df819f
Код
Авторство
О чём код?
// 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; using System.Diagnostics.CodeAnalysis; namespace Roslyn.Test.Utilities.TestGenerators { public sealed class LambdaComparer<T> : IEqualityComparer<T> { private readonly Func<T?, T?, bool> _equal; private readonly int? _hashCode; public LambdaComparer(Func<T?, T?, bool> equal, int? hashCode = null) { _equal = equal; _hashCode = hashCode; } public bool Equals(T? x, T? y) => _equal(x, y); public int GetHashCode([DisallowNull] T obj) => _hashCode.HasValue ? _hashCode.Value : EqualityComparer<T>.Default.GetHashCode(obj); } }