Switch to EquatableArray<T> in ComputeSharp models

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-20 03:11:30 +02:00
1 親 c46c0d0fd4
コミット 23e5300dee
12ファイル変更
+21 -493

検索条件に一致するファイルはありません

+4 -66
ファイルの表示
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.SourceGenerators.Models;
@@ -34,65 +30,7 @@ internal sealed record HlslShaderSourceInfo(
string EntryPoint,
string? ImplicitTextureType,
bool IsSamplerUsed,
ImmutableArray<string> DefinedTypes,
ImmutableArray<string> DefinedConstants,
ImmutableArray<string> MethodSignatures,
ImmutableArray<string> Delegates)
{
/// <inheritdoc/>
public bool Equals(HlslShaderSourceInfo? obj)
{
return Comparer.Default.Equals(this, obj);
}
/// <inheritdoc/>
public override int GetHashCode()
{
return Comparer.Default.GetHashCode(this);
}
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslShaderSourceInfo"/>.
/// </summary>
private sealed class Comparer : Comparer<HlslShaderSourceInfo, Comparer>
{
/// <inheritdoc/>
protected override void AddToHashCode(ref HashCode hashCode, HlslShaderSourceInfo obj)
{
hashCode.Add(obj.HeaderAndThreadsX);
hashCode.Add(obj.ThreadsY);
hashCode.Add(obj.ThreadsZ);
hashCode.Add(obj.Defines);
hashCode.Add(obj.StaticFieldsAndDeclaredTypes);
hashCode.Add(obj.CapturedFieldsAndResourcesAndForwardDeclarations);
hashCode.Add(obj.CapturedMethods);
hashCode.Add(obj.EntryPoint);
hashCode.Add(obj.ImplicitTextureType);
hashCode.Add(obj.IsSamplerUsed);
hashCode.AddRange(obj.DefinedTypes);
hashCode.AddRange(obj.DefinedConstants);
hashCode.AddRange(obj.MethodSignatures);
hashCode.AddRange(obj.Delegates);
}
/// <inheritdoc/>
protected override bool AreEqual(HlslShaderSourceInfo x, HlslShaderSourceInfo y)
{
return
x.HeaderAndThreadsX == y.HeaderAndThreadsX &&
x.ThreadsY == y.ThreadsY &&
x.ThreadsZ == y.ThreadsZ &&
x.Defines == y.Defines &&
x.StaticFieldsAndDeclaredTypes == y.StaticFieldsAndDeclaredTypes &&
x.CapturedFieldsAndResourcesAndForwardDeclarations == y.CapturedFieldsAndResourcesAndForwardDeclarations &&
x.CapturedMethods == y.CapturedMethods &&
x.EntryPoint == y.EntryPoint &&
x.ImplicitTextureType == y.ImplicitTextureType &&
x.IsSamplerUsed == y.IsSamplerUsed &&
x.DefinedTypes.SequenceEqual(y.DefinedTypes) &&
x.DefinedConstants.SequenceEqual(y.DefinedTypes) &&
x.MethodSignatures.SequenceEqual(y.MethodSignatures) &&
x.Delegates.SequenceEqual(y.Delegates);
}
}
}
EquatableArray<string> DefinedTypes,
EquatableArray<string> DefinedConstants,
EquatableArray<string> MethodSignatures,
EquatableArray<string> Delegates);