Switch to EquatableArray<T> in shared models
このコミットが含まれているのは:
1 親
03051082d5
コミット
306cf615ce
4ファイル変更
+12
-123
検索条件に一致するファイルはありません
@@ -70,6 +70,15 @@ internal readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnu
|
|||||||
get => AsImmutableArray().IsEmpty;
|
get => AsImmutableArray().IsEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the current array.
|
||||||
|
/// </summary>
|
||||||
|
public int Length
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get => AsImmutableArray().Length;
|
||||||
|
}
|
||||||
|
|
||||||
/// <sinheritdoc/>
|
/// <sinheritdoc/>
|
||||||
public bool Equals(EquatableArray<T> array)
|
public bool Equals(EquatableArray<T> array)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ComputeSharp.SourceGeneration.Extensions;
|
|
||||||
using ComputeSharp.SourceGeneration.Helpers;
|
using ComputeSharp.SourceGeneration.Helpers;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
@@ -13,20 +10,8 @@ namespace ComputeSharp.SourceGeneration.Models;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Descriptor">The wrapped <see cref="DiagnosticDescriptor"/> instance.</param>
|
/// <param name="Descriptor">The wrapped <see cref="DiagnosticDescriptor"/> instance.</param>
|
||||||
/// <param name="Arguments">The diagnostic arguments.</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>
|
/// <summary>
|
||||||
/// Creates a new <see cref="DeferredDiagnosticInfo"/> instance with the specified parameters.
|
/// Creates a new <see cref="DeferredDiagnosticInfo"/> instance with the specified parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -37,25 +22,4 @@ internal sealed record DeferredDiagnosticInfo(DiagnosticDescriptor Descriptor, I
|
|||||||
{
|
{
|
||||||
return new(descriptor, args.Select(static arg => arg.ToString()).ToImmutableArray());
|
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.Collections.Immutable;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ComputeSharp.SourceGeneration.Extensions;
|
|
||||||
using ComputeSharp.SourceGeneration.Helpers;
|
using ComputeSharp.SourceGeneration.Helpers;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
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="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="TextSpan">The span to use as location for the diagnostic.</param>
|
||||||
/// <param name="Arguments">The diagnostic arguments.</param>
|
/// <param name="Arguments">The diagnostic arguments.</param>
|
||||||
internal sealed record DiagnosticInfo(
|
internal sealed record DiagnosticInfo(DiagnosticDescriptor Descriptor, SyntaxTree? SyntaxTree, TextSpan TextSpan, EquatableArray<string> Arguments)
|
||||||
DiagnosticDescriptor Descriptor,
|
|
||||||
SyntaxTree? SyntaxTree,
|
|
||||||
TextSpan TextSpan,
|
|
||||||
ImmutableArray<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>
|
/// <summary>
|
||||||
/// Creates a new <see cref="Diagnostic"/> instance with the state from this model.
|
/// Creates a new <see cref="Diagnostic"/> instance with the state from this model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -75,29 +56,4 @@ internal sealed record DiagnosticInfo(
|
|||||||
|
|
||||||
return new(descriptor, location.SourceTree, location.SourceSpan, args.Select(static arg => arg.ToString()).ToImmutableArray());
|
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.Extensions;
|
||||||
using ComputeSharp.SourceGeneration.Helpers;
|
using ComputeSharp.SourceGeneration.Helpers;
|
||||||
using Microsoft.CodeAnalysis;
|
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="FullyQualifiedMetadataName">The fully qualified metadata name for the current type.</param>
|
||||||
/// <param name="Namespace">Gets the namespace 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>
|
/// <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>
|
/// <summary>
|
||||||
/// Creates a new <see cref="HierarchyInfo"/> instance from a given <see cref="INamedTypeSymbol"/>.
|
/// 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))
|
.AddMembers(typeDeclarationSyntax))
|
||||||
.NormalizeWhitespace(eol: "\n");
|
.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
新しいイシューから参照
ユーザーをブロックする