using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Models;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
///
/// A model representing all necessary info for a full generation pass for a [D2D1PixelShaderSource] attribute.
///
/// The hierarchy info for the shader type.
/// The processed HLSL source for the shader.
/// The discovered diagnostics, if any.
internal sealed record D2D1PixelShaderSourceInfo(
HierarchyInfo Hierarchy,
HlslShaderMethodSourceInfo HlslShaderMethodSource,
ImmutableArray Diagnostcs)
{
///
public bool Equals(D2D1PixelShaderSourceInfo? obj) => Comparer.Default.Equals(this, obj);
///
public override int GetHashCode() => Comparer.Default.GetHashCode(this);
///
/// An implementation for .
///
private sealed class Comparer : Comparer
{
///
protected override void AddToHashCode(ref HashCode hashCode, D2D1PixelShaderSourceInfo obj)
{
hashCode.Add(obj.Hierarchy);
hashCode.Add(obj.HlslShaderMethodSource);
hashCode.AddRange(obj.Diagnostcs);
}
///
protected override bool AreEqual(D2D1PixelShaderSourceInfo x, D2D1PixelShaderSourceInfo y)
{
return
x.Hierarchy == y.Hierarchy &&
x.HlslShaderMethodSource == y.HlslShaderMethodSource &&
x.Diagnostcs.SequenceEqual(y.Diagnostcs);
}
}
}