Declare and emit new diagnostics
このコミットが含まれているのは:
1 親
4044cff3e8
コミット
65715a5439
3ファイル変更
+51
-3
検索条件に一致するファイルはありません
@@ -89,3 +89,5 @@ CMPSD2D0079 | ComputeSharp.D2D1.Shaders | Warning | [Documentation](https://gith
|
||||
CMPSD2D0080 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0081 | ComputeSharp.D2D1.Shaders | Warning | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0082 | ComputeSharp.D2D1.Shaders | Warning | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0083 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0084 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
+17
-3
@@ -17,7 +17,11 @@ namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
public sealed class InvalidD2DInputArgumentAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = [InvalidD2DEffectIdAttributeValue];
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
|
||||
[
|
||||
IndexOutOfRangeForD2DIntrinsic,
|
||||
InvalidInputTypeForD2DIntrinsic
|
||||
];
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize(AnalysisContext context)
|
||||
@@ -88,13 +92,23 @@ public sealed class InvalidD2DInputArgumentAnalyzer : DiagnosticAnalyzer
|
||||
// First validation: the index must be in range
|
||||
if ((uint)index >= (uint)inputCount)
|
||||
{
|
||||
// TODO: emit diagnostic
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
IndexOutOfRangeForD2DIntrinsic,
|
||||
operation.Syntax.GetLocation(),
|
||||
targetMethodSymbol.Name,
|
||||
index,
|
||||
typeSymbol,
|
||||
inputCount));
|
||||
}
|
||||
|
||||
// Second validation: the input type must match
|
||||
if ((D2D1PixelShaderInputType)inputTypes[index] != targetInputType)
|
||||
{
|
||||
// TODO: emit diagnostic
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
InvalidInputTypeForD2DIntrinsic,
|
||||
operation.Syntax.GetLocation(),
|
||||
targetMethodSymbol.Name,
|
||||
index));
|
||||
}
|
||||
}, OperationKind.Invocation);
|
||||
});
|
||||
|
||||
@@ -1237,4 +1237,36 @@ partial class DiagnosticDescriptors
|
||||
isEnabledByDefault: true,
|
||||
description: "Shaders can only be annotated with [D2DRequiresDoublePrecisionSupport] to perform validation for use of double precision operations if they are precompiled.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a D2D intrinsic call with an out of range input.
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D intrinsic '{0}' cannot be used for input {1}, as the containing shader {2} only declares {3} input(s) (use a valid argument for the D2D intrinsic, or adjust the number of inputs for the shader using [D2DInputCount])"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor IndexOutOfRangeForD2DIntrinsic = new(
|
||||
id: "CMPSD2D0083",
|
||||
title: "Index out of range for D2D intrinsic",
|
||||
messageFormat: "The D2D intrinsic '{0}' cannot be used for input {1}, as the containing shader {2} only declares {3} input(s) (use a valid argument for the D2D intrinsic, or adjust the number of inputs for the shader using [D2DInputCount])",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "D2D intrinsics must be used with valid input indices (the number of inputs for a shader can be configured using [D2DInputCount]).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a D2D intrinsic call with an invalid input type.
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D intrinsic '{0}' cannot be used for input {1}, as it does not have the right input type (you can configure the input type of each input using [D2DInputSimple] and [D2DInputComplex] on the shader type)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidInputTypeForD2DIntrinsic = new(
|
||||
id: "CMPSD2D0084",
|
||||
title: "Invalid input type for D2D intrinsic",
|
||||
messageFormat: "The D2D intrinsic '{0}' cannot be used for input {1}, as it does not have the right input type (you can configure the input type of each input using [D2DInputSimple] and [D2DInputComplex] on the shader type)",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "D2D intrinsics must be used with compatible input types (the input type of each shader input can be configured using [D2DInputSimple] and [D2DInputComplex] on the shader type).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする