Minor tweaks to DiagnosticInfo

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-17 12:26:38 +01:00
1 親 cea25fbd4d
コミット e27b7e4379
4ファイル変更
+29 -8

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

@@ -257,14 +257,17 @@ partial class D2DPixelShaderDescriptorGenerator
diagnostic = DiagnosticInfo.Create(
HlslBytecodeFailedWithWin32Exception,
structDeclarationSymbol,
[structDeclarationSymbol, win32Error.HResult, win32Error.Message]);
structDeclarationSymbol,
win32Error.HResult,
win32Error.Message);
}
else if (info is HlslBytecodeInfo.CompilerError fxcError)
{
diagnostic = DiagnosticInfo.Create(
HlslBytecodeFailedWithFxcCompilationException,
structDeclarationSymbol,
[structDeclarationSymbol, fxcError.Message]);
structDeclarationSymbol,
fxcError.Message);
}
if (diagnostic is not null)
+7 -2
ファイルの表示
@@ -140,14 +140,19 @@ partial class D2DPixelShaderSourceGenerator
diagnostic = DiagnosticInfo.Create(
D2DPixelShaderSourceCompilationFailedWithWin32Exception,
methodSymbol,
[methodSymbol, methodSymbol.ContainingType, win32Error.HResult, win32Error.Message]);
methodSymbol,
methodSymbol.ContainingType,
win32Error.HResult,
win32Error.Message);
}
else if (info is HlslBytecodeInfo.CompilerError fxcError)
{
diagnostic = DiagnosticInfo.Create(
D2DPixelShaderSourceCompilationFailedWithFxcCompilationException,
methodSymbol,
[methodSymbol, methodSymbol.ContainingType, fxcError.Message]);
methodSymbol,
methodSymbol.ContainingType,
fxcError.Message);
}
if (diagnostic is not null)
+12 -2
ファイルの表示
@@ -42,7 +42,17 @@ internal sealed record DiagnosticInfo(
/// <returns>A new <see cref="DiagnosticInfo"/> instance with the specified parameters.</returns>
public static DiagnosticInfo Create(DiagnosticDescriptor descriptor, Location? location, params object[] args)
{
return new(descriptor, location?.SourceTree, location?.SourceSpan ?? default, args.Select(static arg => arg.ToString()).ToImmutableArray());
// The returned DiagnosticInfo instances will be used inside incremental collections. Because of
// that, we pre-transform all arguments with ToString(), so they are guaranteed to be equatable
// from the start and not to keep compilations alive (if eg. they happen to be symbol objects).
EquatableArray<string> textArgs = args.Select(static arg => arg.ToString()).ToImmutableArray();
if (location is null)
{
return new(descriptor, null, default, textArgs);
}
return new(descriptor, location.SourceTree, location.SourceSpan, textArgs);
}
/// <summary>
@@ -54,7 +64,7 @@ internal sealed record DiagnosticInfo(
/// <returns>A new <see cref="DiagnosticInfo"/> instance with the specified parameters.</returns>
public static DiagnosticInfo Create(DiagnosticDescriptor descriptor, ISymbol symbol, params object[] args)
{
return Create(descriptor, symbol.Locations.First(), args);
return Create(descriptor, symbol.Locations.FirstOrDefault(), args);
}
/// <summary>
+5 -2
ファイルの表示
@@ -124,14 +124,17 @@ partial class ComputeShaderDescriptorGenerator
diagnostic = DiagnosticInfo.Create(
HlslBytecodeFailedWithWin32Exception,
structDeclarationSymbol,
[structDeclarationSymbol, win32Error.HResult, win32Error.Message]);
structDeclarationSymbol,
win32Error.HResult,
win32Error.Message);
}
else if (info is HlslBytecodeInfo.CompilerError dxcError)
{
diagnostic = DiagnosticInfo.Create(
HlslBytecodeFailedWithDxcCompilationException,
structDeclarationSymbol,
[structDeclarationSymbol, dxcError.Message]);
structDeclarationSymbol,
dxcError.Message);
}
if (diagnostic is not null)