Added diagnostics for invalid DispatchSize usage
このコミットが含まれているのは:
1 親
ced4a12afd
コミット
1b531f1dd7
5ファイル変更
+54
-1
検索条件に一致するファイルはありません
@@ -50,4 +50,5 @@ CMPS0042 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator,
|
||||
CMPS0043 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0044 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0045 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0046 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0046 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0047 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -652,5 +652,18 @@ namespace ComputeSharp.SourceGenerators.Diagnostics
|
||||
isEnabledByDefault: true,
|
||||
description: "A type representing a compute shader contains an instance property declaration.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid <see cref="DispatchSize"/> usage.
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidDispatchSizeUsage = new(
|
||||
id: "CMPS0047",
|
||||
title: "Invalid DispatchSize usage",
|
||||
messageFormat: "The DispatchSize type can only be used within the main body of a compute shader",
|
||||
category: typeof(IComputeShader).FullName,
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The DispatchSize type can only be used within the main body of a compute shader.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
_ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage,
|
||||
_ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage,
|
||||
_ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage,
|
||||
_ when typeName == typeof(DispatchSize).FullName => InvalidDispatchSizeUsage,
|
||||
_ => null
|
||||
};
|
||||
|
||||
|
||||
@@ -288,6 +288,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
_ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage,
|
||||
_ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage,
|
||||
_ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage,
|
||||
_ when typeName == typeof(DispatchSize).FullName => InvalidDispatchSizeUsage,
|
||||
_ => null
|
||||
};
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ namespace ComputeSharp.Tests.SourceGenerators
|
||||
[DataRow(nameof(GroupIds), "CMPS0007")]
|
||||
[DataRow(nameof(GroupSize), "CMPS0008")]
|
||||
[DataRow(nameof(GridIds), "CMPS0009")]
|
||||
[DataRow(nameof(DispatchSize), "CMPS0047")]
|
||||
public void InvalidDispatchInfoUsage_LocalFunction(string typeName, string diagnosticsId)
|
||||
{
|
||||
string source = $@"
|
||||
@@ -176,6 +177,7 @@ namespace ComputeSharp.Tests.SourceGenerators
|
||||
[DataRow(nameof(GroupIds), "CMPS0007")]
|
||||
[DataRow(nameof(GroupSize), "CMPS0008")]
|
||||
[DataRow(nameof(GridIds), "CMPS0009")]
|
||||
[DataRow(nameof(DispatchSize), "CMPS0047")]
|
||||
public void InvalidDispatchInfoUsage_StaticMethod(string typeName, string diagnosticsId)
|
||||
{
|
||||
string source = $@"
|
||||
@@ -202,6 +204,41 @@ namespace ComputeSharp.Tests.SourceGenerators
|
||||
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, diagnosticsId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(nameof(ThreadIds), "CMPS0006")]
|
||||
[DataRow(nameof(GroupIds), "CMPS0007")]
|
||||
[DataRow(nameof(GroupSize), "CMPS0008")]
|
||||
[DataRow(nameof(GridIds), "CMPS0009")]
|
||||
[DataRow(nameof(DispatchSize), "CMPS0047")]
|
||||
public void InvalidDispatchInfoUsage_ConstantProperty(string typeName, string diagnosticsId)
|
||||
{
|
||||
string source = $@"
|
||||
using ComputeSharp;
|
||||
|
||||
namespace ComputeSharp
|
||||
{{
|
||||
public class ReadWriteBuffer<T> {{ }}
|
||||
public static class {typeName} {{ public static int X => 0; }}
|
||||
}}
|
||||
|
||||
namespace MyFancyApp.Sample
|
||||
{{
|
||||
public struct MyShader : IComputeShader
|
||||
{{
|
||||
public ReadWriteBuffer<float> buffer;
|
||||
|
||||
private static int Foo => {typeName}.X;
|
||||
|
||||
public void Execute()
|
||||
{{
|
||||
buffer[0] = Foo;
|
||||
}}
|
||||
}}
|
||||
}}";
|
||||
|
||||
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, diagnosticsId);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void InvalidObjectCreationExpression_Explicit()
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする