Enable diagnostics from bytecode transformation
このコミットが含まれているのは:
1 親
2209c9eb41
コミット
2e160c5caa
4ファイル変更
+100
-27
検索条件に一致するファイルはありません
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGenerators.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model for a serializeable diagnostic provider.
|
||||
/// </summary>
|
||||
/// <param name="Descriptor">The wrapped <see cref="DiagnosticDescriptor"/> instance.</param>
|
||||
/// <param name="Args">The diagnostic args.</param>
|
||||
internal sealed record DiagnosticInfo(DiagnosticDescriptor Descriptor, params object[] Args)
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DiagnosticInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<DiagnosticInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DiagnosticInfo? x, DiagnosticInfo? y)
|
||||
{
|
||||
if (x is null && y is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x is null || y is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return
|
||||
x.Descriptor.Equals(y.Descriptor) &&
|
||||
x.Args.SequenceEqual(y.Args);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(DiagnosticInfo obj)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.Add(obj.Descriptor);
|
||||
|
||||
foreach (object arg in obj.Args)
|
||||
{
|
||||
hashCode.Add(arg);
|
||||
}
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,10 @@ namespace ComputeSharp.SourceGenerators.Models;
|
||||
/// A model describing the hierarchy info for a specific type.
|
||||
/// </summary>
|
||||
/// <param name="FilenameHint">The filename hint for the current type.</param>
|
||||
/// <param name="MetadataName">The metadata name for the current type.</param>
|
||||
/// <param name="Namespace">Gets the namespace for the current type.</param>
|
||||
/// <param name="Names">Gets the sequence of type definitions containing the current type.</param>
|
||||
internal sealed record HierarchyInfo(string FilenameHint, string Namespace, ImmutableArray<string> Names)
|
||||
internal sealed record HierarchyInfo(string FilenameHint, string MetadataName, string Namespace, ImmutableArray<string> Names)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HierarchyInfo"/> instance from a given <see cref="INamedTypeSymbol"/>.
|
||||
@@ -35,6 +36,7 @@ internal sealed record HierarchyInfo(string FilenameHint, string Namespace, Immu
|
||||
|
||||
return new(
|
||||
typeSymbol.GetGeneratedFileName(),
|
||||
typeSymbol.MetadataName,
|
||||
typeSymbol.ContainingNamespace.ToDisplayString(new(typeQualificationStyle: NameAndContainingTypesAndNamespaces)),
|
||||
names.ToImmutable());
|
||||
}
|
||||
@@ -69,6 +71,7 @@ internal sealed record HierarchyInfo(string FilenameHint, string Namespace, Immu
|
||||
|
||||
return
|
||||
x.FilenameHint == y.FilenameHint &&
|
||||
x.MetadataName == y.MetadataName &&
|
||||
x.Namespace == y.Namespace &&
|
||||
x.Names.SequenceEqual(y.Names);
|
||||
}
|
||||
@@ -76,7 +79,7 @@ internal sealed record HierarchyInfo(string FilenameHint, string Namespace, Immu
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(HierarchyInfo obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Namespace, obj.Names, obj.Names[0]);
|
||||
return HashCode.Combine(obj.Namespace, obj.MetadataName, obj.Names, obj.Names[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする