Further optimize diagnostics in D2DPixelShaderSourceGenerator

このコミットが含まれているのは:
Sergio Pedri committed 2024-01-07 00:38:59 +01:00
1 親 37b820b670
コミット 40874d5d16
2ファイル変更
+13 -18

検索条件に一致するファイルはありません

+10 -13
ファイルの表示
@@ -1,3 +1,4 @@
using System.Collections.Immutable;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
@@ -98,38 +99,34 @@ partial class D2DPixelShaderSourceGenerator
/// </summary>
/// <param name="methodSymbol">The input <see cref="IMethodSymbol"/> instance to process.</param>
/// <param name="info">The source <see cref="HlslBytecodeInfo"/> instance.</param>
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
public static void GetInfoDiagnostics(
IMethodSymbol methodSymbol,
HlslBytecodeInfo info,
ImmutableArrayBuilder<DiagnosticInfo> diagnostics)
/// <returns>The collection of produced <see cref="DiagnosticInfo"/> instances.</returns>
public static ImmutableArray<DiagnosticInfo> GetInfoDiagnostics(IMethodSymbol methodSymbol, HlslBytecodeInfo info)
{
DiagnosticInfo? diagnostic = null;
if (info is HlslBytecodeInfo.Win32Error win32Error)
{
diagnostic = DiagnosticInfo.Create(
DiagnosticInfo diagnostic = DiagnosticInfo.Create(
D2DPixelShaderSourceCompilationFailedWithWin32Exception,
methodSymbol,
methodSymbol,
methodSymbol.ContainingType,
win32Error.HResult,
win32Error.Message);
return ImmutableArray.Create(diagnostic);
}
else if (info is HlslBytecodeInfo.CompilerError fxcError)
{
diagnostic = DiagnosticInfo.Create(
DiagnosticInfo diagnostic = DiagnosticInfo.Create(
D2DPixelShaderSourceCompilationFailedWithFxcCompilationException,
methodSymbol,
methodSymbol,
methodSymbol.ContainingType,
fxcError.Message);
return ImmutableArray.Create(diagnostic);
}
if (diagnostic is not null)
{
diagnostics.Add(diagnostic);
}
return ImmutableArray<DiagnosticInfo>.Empty;
}
/// <summary>
+3 -5
ファイルの表示
@@ -35,8 +35,6 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
MethodDeclarationSyntax methodDeclaration = (MethodDeclarationSyntax)context.TargetNode;
IMethodSymbol methodSymbol = (IMethodSymbol)context.TargetSymbol;
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = new();
// Get the remaining info for the current shader
ImmutableArray<ushort> modifiers = methodDeclaration.Modifiers.Select(token => (ushort)token.Kind()).ToImmutableArray();
string methodName = methodSymbol.Name;
@@ -65,8 +63,8 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
token.ThrowIfCancellationRequested();
// Append any diagnostic for the shader compilation
Execute.GetInfoDiagnostics(methodSymbol, hlslInfo, diagnostics);
// Get any diagnostics for the shader compilation
ImmutableArray<DiagnosticInfo> diagnostics = Execute.GetInfoDiagnostics(methodSymbol, hlslInfo);
token.ThrowIfCancellationRequested();
@@ -82,7 +80,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
InvalidReturnType: invalidReturnType,
HlslInfoKey: hlslInfoKey,
HlslInfo: hlslInfo,
Diagnostcs: diagnostics.ToImmutable());
Diagnostcs: diagnostics);
})
.WithTrackingName(WellKnownTrackingNames.Execute);