Refactor diagnostic models to be properly equatable
このコミットが含まれているのは:
1 親
bdaf402a4c
コミット
9eac3c779d
26ファイル変更
+247
-134
検索条件に一致するファイルはありません
@@ -1,5 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.Extensions;
|
||||
@@ -12,33 +12,33 @@ internal static class DiagnosticsExtensions
|
||||
/// <summary>
|
||||
/// Adds a new diagnostics to the target builder.
|
||||
/// </summary>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="Diagnostic"/> instances.</param>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
/// <param name="descriptor">The input <see cref="DiagnosticDescriptor"/> for the diagnostics to create.</param>
|
||||
/// <param name="symbol">The source <see cref="ISymbol"/> to attach the diagnostics to.</param>
|
||||
/// <param name="args">The optional arguments for the formatted message to include.</param>
|
||||
public static void Add(
|
||||
this ImmutableArray<Diagnostic>.Builder diagnostics,
|
||||
this ImmutableArray<DiagnosticInfo>.Builder diagnostics,
|
||||
DiagnosticDescriptor descriptor,
|
||||
ISymbol symbol,
|
||||
params object[] args)
|
||||
{
|
||||
diagnostics.Add(Diagnostic.Create(descriptor, symbol.Locations.FirstOrDefault(), args));
|
||||
diagnostics.Add(DiagnosticInfo.Create(descriptor, symbol, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new diagnostics to the target builder.
|
||||
/// </summary>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="Diagnostic"/> instances.</param>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
/// <param name="descriptor">The input <see cref="DiagnosticDescriptor"/> for the diagnostics to create.</param>
|
||||
/// <param name="node">The source <see cref="SyntaxNode"/> to attach the diagnostics to.</param>
|
||||
/// <param name="args">The optional arguments for the formatted message to include.</param>
|
||||
public static void Add(
|
||||
this ImmutableArray<Diagnostic>.Builder diagnostics,
|
||||
this ImmutableArray<DiagnosticInfo>.Builder diagnostics,
|
||||
DiagnosticDescriptor descriptor,
|
||||
SyntaxNode node,
|
||||
params object[] args)
|
||||
{
|
||||
diagnostics.Add(Diagnostic.Create(descriptor, node.GetLocation(), args));
|
||||
diagnostics.Add(DiagnosticInfo.Create(descriptor, node, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,11 +46,11 @@ internal static class DiagnosticsExtensions
|
||||
/// </summary>
|
||||
/// <param name="context">The input <see cref="IncrementalGeneratorInitializationContext"/> instance.</param>
|
||||
/// <param name="diagnostics">The input <see cref="IncrementalValuesProvider{TValues}"/> sequence of diagnostics.</param>
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<Diagnostic> diagnostics)
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<DiagnosticInfo> diagnostics)
|
||||
{
|
||||
context.RegisterSourceOutput(diagnostics, static (context, diagnostic) =>
|
||||
{
|
||||
context.ReportDiagnostic(diagnostic);
|
||||
context.ReportDiagnostic(diagnostic.ToDiagnostic());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ internal static class DiagnosticsExtensions
|
||||
/// </summary>
|
||||
/// <param name="context">The input <see cref="IncrementalGeneratorInitializationContext"/> instance.</param>
|
||||
/// <param name="diagnostics">The input <see cref="IncrementalValuesProvider{TValues}"/> sequence of diagnostics.</param>
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<ImmutableArray<Diagnostic>> diagnostics)
|
||||
public static void ReportDiagnostics(this IncrementalGeneratorInitializationContext context, IncrementalValuesProvider<ImmutableArray<DiagnosticInfo>> diagnostics)
|
||||
{
|
||||
context.RegisterSourceOutput(diagnostics, static (context, diagnostics) =>
|
||||
{
|
||||
foreach (Diagnostic diagnostic in diagnostics)
|
||||
foreach (DiagnosticInfo diagnostic in diagnostics)
|
||||
{
|
||||
context.ReportDiagnostic(diagnostic);
|
||||
context.ReportDiagnostic(diagnostic.ToDiagnostic());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ internal static class IEqualityComparerExtensions
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for an <see cref="ImmutableArray{T}"/> value.
|
||||
/// </summary>
|
||||
public sealed class Comparer<T> : IEqualityComparer<ImmutableArray<T>>
|
||||
private sealed class Comparer<T> : IEqualityComparer<ImmutableArray<T>>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <typeparamref name="T"/> comparer.
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする