Add MissingComputeShaderDescriptorOnComputeShaderCodeFixer

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-16 10:50:40 +02:00
1 親 1075dc7e0b
コミット d6096b525a
2ファイル変更
+41

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

@@ -0,0 +1,36 @@
using System.Composition;
using ComputeSharp.CodeFixing;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
namespace ComputeSharp.D2D1.CodeFixers;
/// <summary>
/// A code fixer that adds the <c>[GeneratedComputeShaderDescriptor]</c> to compute shader types with no descriptor.
/// </summary>
[ExportCodeFixProvider(LanguageNames.CSharp)]
[Shared]
public sealed class MissingComputeShaderDescriptorOnComputeShaderCodeFixer : MissingAttributeCodeFixer
{
/// <summary>
/// The set of type names for all attributes that can be over shader types.
/// </summary>
private static readonly string[] D2DAttributeTypeNames = new[]
{
"ComputeSharp.EmbeddedBytecodeAttribute",
"ComputeSharp.GroupSharedAttribute"
};
/// <summary>
/// Creates a new <see cref="MissingAttributeCodeFixer"/> instance with the specified parameters.
/// </summary>
public MissingComputeShaderDescriptorOnComputeShaderCodeFixer()
: base(
diagnosticId: MissingComputeShaderDescriptorOnComputeShaderTypeId,
codeActionTitle: "Add [GeneratedComputeShaderDescriptor] attribute",
attributeFullyQualifiedMetadataName: "ComputeSharp.GeneratedComputeShaderDescriptorAttribute",
leadingAttributeFullyQualifiedMetadataNames: D2DAttributeTypeNames)
{
}
}