Add diagnostic for missing [D2DResourceTextureIndex] attribute

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-08 15:45:45 +02:00
1 親 a3635b09d9
コミット 21328f54a5
3ファイル変更
+18 -1

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

+1
ファイルの表示
@@ -56,3 +56,4 @@ CMPSD2D0046 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github
CMPSD2D0047 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPSD2D0048 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPSD2D0049 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPSD2D0050 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
+16
ファイルの表示
@@ -714,4 +714,20 @@ internal static class DiagnosticDescriptors
isEnabledByDefault: true,
description: "A field is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types).",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
/// <summary>
/// Gets a <see cref="DiagnosticDescriptor"/> for a missing <c>[D2DResourceTextureIndex]</c>.
/// <para>
/// Format: <c>"The field \"{0}\" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute"</c>.
/// </para>
/// </summary>
public static readonly DiagnosticDescriptor MissingD2DResourceTextureIndexAttribute = new DiagnosticDescriptor(
id: "CMPSD2D0050",
title: "Missing [D2DResourceTextureIndex] attribute",
messageFormat: "The field \"{0}\" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute",
category: "ComputeSharp.D2D1.Shaders",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "All fields of a D2D1 resource texture type must be annotated using the [D2DResourceTextureIndex] attribute.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
}
@@ -61,7 +61,7 @@ partial class ID2D1ShaderGenerator
else
{
// If the attribute is missing, emit a diagnostic
// TODO
diagnostics.Add(MissingD2DResourceTextureIndexAttribute, fieldSymbol, fieldSymbol.Name, structDeclarationSymbol);
}
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);