diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs index ca539802..1c58c1fb 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using ComputeSharp.D2D1.SourceGenerators.Models; @@ -63,8 +62,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato // Output the diagnostics context.ReportDiagnostics( shaderInfoWithErrors - .Select(static (item, _) => item.Diagnostcs.AsImmutableArray()) - .WithComparer(EqualityComparer.Default.ForImmutableArray())); + .Select(static (item, _) => item.Diagnostcs)); // Compile the requested shader bytecodes IncrementalValuesProvider<(HierarchyInfo Hierarchy, EmbeddedBytecodeMethodInfo BytecodeInfo, DeferredDiagnosticInfo? Diagnostic)> embeddedBytecodeWithErrors = diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs index 85e264f0..ed1238b5 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Text; @@ -135,8 +134,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator // Output the diagnostics, if any context.ReportDiagnostics( shaderInfoWithErrors - .Select(static (item, _) => item.Diagnostcs.AsImmutableArray()) - .WithComparer(EqualityComparer.Default.ForImmutableArray())); + .Select(static (item, _) => item.Diagnostcs)); // Get the GetInputCount() info (hierarchy and input count) IncrementalValuesProvider<(HierarchyInfo Hierarchy, int InputCount)> inputCountInfo = diff --git a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems index 6a561e17..b17d1faf 100644 --- a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems +++ b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems @@ -14,7 +14,6 @@ - diff --git a/src/ComputeSharp.SourceGeneration/Extensions/DiagnosticsExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/DiagnosticsExtensions.cs index 4d6d3717..033be458 100644 --- a/src/ComputeSharp.SourceGeneration/Extensions/DiagnosticsExtensions.cs +++ b/src/ComputeSharp.SourceGeneration/Extensions/DiagnosticsExtensions.cs @@ -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 /// /// The input instance. /// The input sequence of diagnostics. - public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider> diagnostics) + public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider> diagnostics) { context.RegisterSourceOutput(diagnostics, static (context, diagnostics) => { diff --git a/src/ComputeSharp.SourceGeneration/Extensions/IEqualityComparerExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/IEqualityComparerExtensions.cs deleted file mode 100644 index ff7734fb..00000000 --- a/src/ComputeSharp.SourceGeneration/Extensions/IEqualityComparerExtensions.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace ComputeSharp.SourceGeneration.Extensions; - -/// -/// Extension methods for . -/// -internal static class IEqualityComparerExtensions -{ - /// - /// Gets an for an sequence. - /// - /// The type of items to compare. - /// The compare for individual items. - public static IEqualityComparer> ForImmutableArray(this IEqualityComparer comparer) - { - return new Comparer(comparer); - } - - /// - /// An implementation for an value. - /// - private sealed class Comparer : IEqualityComparer> - { - /// - /// The comparer. - /// - private readonly IEqualityComparer comparer; - - /// - /// Creates a new instance with the specified parameters. - /// - /// The comparer. - public Comparer(IEqualityComparer comparer) - { - this.comparer = comparer; - } - - /// - public bool Equals(ImmutableArray x, ImmutableArray y) - { - return - x == y || - x.SequenceEqual(y, this.comparer); - } - - /// - public int GetHashCode(ImmutableArray obj) - { - HashCode hashCode = default; - - hashCode.AddRange(obj, this.comparer); - - return hashCode.ToHashCode(); - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs index c5791f36..f5288781 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Text; @@ -118,8 +117,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator // Output the diagnostics, if any context.ReportDiagnostics( shaderInfoWithErrors - .Select(static (item, _) => item.Diagnostcs.AsImmutableArray()) - .WithComparer(EqualityComparer.Default.ForImmutableArray())); + .Select(static (item, _) => item.Diagnostcs)); // Get the GetDispatchId() info (hierarchy and dispatch id info) IncrementalValuesProvider<(HierarchyInfo Hierarchy, DispatchIdInfo DispatchId)> dispatchIdInfo = diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index 4a4163fa..21e5888a 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -48,8 +48,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator // Output the diagnostics, if any context.ReportDiagnostics( methodInfoWithErrors - .Select(static (item, _) => item.Diagnostcs.AsImmutableArray()) - .WithComparer(EqualityComparer.Default.ForImmutableArray())); + .Select(static (item, _) => item.Diagnostcs)); // Generate the [ShaderMethodSource] attributes context.RegisterSourceOutput(methodInfoWithErrors, static (context, item) =>