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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
@@ -16,24 +13,8 @@ namespace ComputeSharp.SourceGeneration.Models;
|
||||
/// <param name="SyntaxTree">The tree to use as location for the diagnostic, if available.</param>
|
||||
/// <param name="TextSpan">The span to use as location for the diagnostic.</param>
|
||||
/// <param name="Arguments">The diagnostic arguments.</param>
|
||||
internal sealed record DiagnosticInfo(
|
||||
DiagnosticDescriptor Descriptor,
|
||||
SyntaxTree? SyntaxTree,
|
||||
TextSpan TextSpan,
|
||||
ImmutableArray<string> Arguments)
|
||||
internal sealed record DiagnosticInfo(DiagnosticDescriptor Descriptor, SyntaxTree? SyntaxTree, TextSpan TextSpan, EquatableArray<string> Arguments)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DiagnosticInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Diagnostic"/> instance with the state from this model.
|
||||
/// </summary>
|
||||
@@ -75,29 +56,4 @@ internal sealed record DiagnosticInfo(
|
||||
|
||||
return new(descriptor, location.SourceTree, location.SourceSpan, args.Select(static arg => arg.ToString()).ToImmutableArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DiagnosticInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<DiagnosticInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DiagnosticInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.Descriptor);
|
||||
hashCode.Add(obj.SyntaxTree);
|
||||
hashCode.Add(obj.TextSpan);
|
||||
hashCode.AddRange(obj.Arguments);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(DiagnosticInfo x, DiagnosticInfo y)
|
||||
{
|
||||
return
|
||||
x.Descriptor.Equals(y.Descriptor) &&
|
||||
x.SyntaxTree == y.SyntaxTree &&
|
||||
x.TextSpan.Equals(y.TextSpan) &&
|
||||
x.Arguments.SequenceEqual(y.Arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
@@ -18,7 +15,7 @@ namespace ComputeSharp.SourceGeneration.Models;
|
||||
/// <param name="FullyQualifiedMetadataName">The fully qualified metadata name for the current type.</param>
|
||||
/// <param name="Namespace">Gets the namespace for the current type.</param>
|
||||
/// <param name="Hierarchy">Gets the sequence of type definitions containing the current type.</param>
|
||||
internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQualifiedMetadataName, string Namespace, ImmutableArray<TypeInfo> Hierarchy)
|
||||
internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQualifiedMetadataName, string Namespace, EquatableArray<TypeInfo> Hierarchy)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HierarchyInfo"/> instance from a given <see cref="INamedTypeSymbol"/>.
|
||||
@@ -110,41 +107,4 @@ internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQu
|
||||
.AddMembers(typeDeclarationSyntax))
|
||||
.NormalizeWhitespace(eol: "\n");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(HierarchyInfo? 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="HierarchyInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<HierarchyInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, HierarchyInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.FilenameHint);
|
||||
hashCode.Add(obj.FullyQualifiedMetadataName);
|
||||
hashCode.Add(obj.Namespace);
|
||||
hashCode.AddRange(obj.Hierarchy);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(HierarchyInfo x, HierarchyInfo y)
|
||||
{
|
||||
return
|
||||
x.FilenameHint == y.FilenameHint &&
|
||||
x.FullyQualifiedMetadataName == y.FullyQualifiedMetadataName &&
|
||||
x.Namespace == y.Namespace &&
|
||||
x.Hierarchy.SequenceEqual(y.Hierarchy);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする