Enabled diagnostics for invalid ThreadIds.Normalized usage

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-08 14:42:12 +01:00
1 親 1b531f1dd7
コミット 0ff4da8480
3ファイル変更
+32 -2

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

+1 -1
ファイルの表示
@@ -83,7 +83,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
// Special dispatch types are not supported from static constants
DiagnosticDescriptor? descriptor = typeName switch
{
_ when typeName == typeof(ThreadIds).FullName => InvalidThreadIdsUsage,
_ when typeName == typeof(ThreadIds).FullName || typeName == typeof(ThreadIds.Normalized).FullName => InvalidThreadIdsUsage,
_ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage,
_ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage,
_ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage,
+1 -1
ファイルの表示
@@ -284,7 +284,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
{
DiagnosticDescriptor? descriptor = typeName switch
{
_ when typeName == typeof(ThreadIds).FullName => InvalidThreadIdsUsage,
_ when typeName == typeof(ThreadIds).FullName || typeName == typeof(ThreadIds.Normalized).FullName => InvalidThreadIdsUsage,
_ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage,
_ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage,
_ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage,
+30
ファイルの表示
@@ -239,6 +239,36 @@ namespace ComputeSharp.Tests.SourceGenerators
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, diagnosticsId);
}
[TestMethod]
public void InvalidThreadIdsNormalizedUsage()
{
string source = $@"
using ComputeSharp;
namespace ComputeSharp
{{
public class ReadWriteBuffer<T> {{ }}
public static class ThreadIds {{ public static class Normalized {{ public static int X => 0; }} }}
}}
namespace MyFancyApp.Sample
{{
public struct MyShader : IComputeShader
{{
public ReadWriteBuffer<float> buffer;
private static int Foo => ThreadIds.Normalized.X;
public void Execute()
{{
buffer[0] = Foo;
}}
}}
}}";
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, "CMPS0006");
}
[TestMethod]
public void InvalidObjectCreationExpression_Explicit()
{