Switch to EquatableArray<T> in shared models
このコミットが含まれているのは:
1 親
03051082d5
コミット
306cf615ce
4ファイル変更
+12
-123
検索条件に一致するファイルはありません
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
@@ -13,20 +10,8 @@ namespace ComputeSharp.SourceGeneration.Models;
|
||||
/// </summary>
|
||||
/// <param name="Descriptor">The wrapped <see cref="DiagnosticDescriptor"/> instance.</param>
|
||||
/// <param name="Arguments">The diagnostic arguments.</param>
|
||||
internal sealed record DeferredDiagnosticInfo(DiagnosticDescriptor Descriptor, ImmutableArray<string> Arguments)
|
||||
internal sealed record DeferredDiagnosticInfo(DiagnosticDescriptor Descriptor, EquatableArray<string> Arguments)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DeferredDiagnosticInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeferredDiagnosticInfo"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -37,25 +22,4 @@ internal sealed record DeferredDiagnosticInfo(DiagnosticDescriptor Descriptor, I
|
||||
{
|
||||
return new(descriptor, args.Select(static arg => arg.ToString()).ToImmutableArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DeferredDiagnosticInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<DeferredDiagnosticInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DeferredDiagnosticInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.Descriptor);
|
||||
hashCode.AddRange(obj.Arguments);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(DeferredDiagnosticInfo x, DeferredDiagnosticInfo y)
|
||||
{
|
||||
return
|
||||
x.Descriptor.Equals(y.Descriptor) &&
|
||||
x.Arguments.SequenceEqual(y.Arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする