diff --git a/src/ComputeSharp.D2D1.SourceGenerators/AnalyzerReleases.Shipped.md b/src/ComputeSharp.D2D1.SourceGenerators/AnalyzerReleases.Shipped.md
index 4887a339..6dd956e8 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/AnalyzerReleases.Shipped.md
+++ b/src/ComputeSharp.D2D1.SourceGenerators/AnalyzerReleases.Shipped.md
@@ -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)
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DInputArgumentAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DInputArgumentAnalyzer.cs
index 1fd30eca..c2d0fc07 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DInputArgumentAnalyzer.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DInputArgumentAnalyzer.cs
@@ -17,7 +17,11 @@ namespace ComputeSharp.D2D1.SourceGenerators;
public sealed class InvalidD2DInputArgumentAnalyzer : DiagnosticAnalyzer
{
///
- public override ImmutableArray SupportedDiagnostics { get; } = [InvalidD2DEffectIdAttributeValue];
+ public override ImmutableArray SupportedDiagnostics { get; } =
+ [
+ IndexOutOfRangeForD2DIntrinsic,
+ InvalidInputTypeForD2DIntrinsic
+ ];
///
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);
});
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
index 6e8dd5b9..148bedf5 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs
@@ -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");
+
+ ///
+ /// Gets a for a D2D intrinsic call with an out of range input.
+ ///
+ /// Format: "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])".
+ ///
+ ///
+ 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");
+
+ ///
+ /// Gets a for a D2D intrinsic call with an invalid input type.
+ ///
+ /// Format: "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)".
+ ///
+ ///
+ 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");
}
\ No newline at end of file