Remove IEqualityComparerExtensions
このコミットが含まれているのは:
1 親
76da654352
コミット
ac89019292
7ファイル変更
+5
-73
検索条件に一致するファイルはありません
@@ -1,4 +1,3 @@
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
@@ -57,7 +56,7 @@ internal static class DiagnosticsExtensions
|
||||
/// </summary>
|
||||
/// <param name="context">The input <see cref="IncrementalGeneratorInitializationContext"/> instance.</param>
|
||||
/// <param name="diagnostics">The input <see cref="IncrementalValuesProvider{TValues}"/> sequence of diagnostics.</param>
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<ImmutableArray<DiagnosticInfo>> diagnostics)
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<EquatableArray<DiagnosticInfo>> diagnostics)
|
||||
{
|
||||
context.RegisterSourceOutput(diagnostics, static (context, diagnostics) =>
|
||||
{
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IEqualityComparer{T}"/>.
|
||||
/// </summary>
|
||||
internal static class IEqualityComparerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IEqualityComparer{T}"/> for an <see cref="ImmutableArray{T}"/> sequence.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to compare.</typeparam>
|
||||
/// <param name="comparer">The compare for individual <typeparamref name="T"/> items.</param>
|
||||
public static IEqualityComparer<ImmutableArray<T>> ForImmutableArray<T>(this IEqualityComparer<T> comparer)
|
||||
{
|
||||
return new Comparer<T>(comparer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for an <see cref="ImmutableArray{T}"/> value.
|
||||
/// </summary>
|
||||
private sealed class Comparer<T> : IEqualityComparer<ImmutableArray<T>>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <typeparamref name="T"/> comparer.
|
||||
/// </summary>
|
||||
private readonly IEqualityComparer<T> comparer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Comparer{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="comparer">The <typeparamref name="T"/> comparer.</param>
|
||||
public Comparer(IEqualityComparer<T> comparer)
|
||||
{
|
||||
this.comparer = comparer;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(ImmutableArray<T> x, ImmutableArray<T> y)
|
||||
{
|
||||
return
|
||||
x == y ||
|
||||
x.SequenceEqual(y, this.comparer);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(ImmutableArray<T> obj)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.AddRange(obj, this.comparer);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする