Add unit tests for annotated generic shader types

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-26 16:35:32 +01:00
1 親 bf7c470cb3
コミット 41b68eaa5a
2ファイル変更
+112

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

+58
ファイルの表示
@@ -138,4 +138,62 @@ public class Test_Analyzers
await CSharpAnalyzerWithLanguageVersionTest<NotReadOnlyPixelShaderTypeWithFieldsAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidD2DGeneratedPixelShaderDescriptorAttributeTarget_NoInterface()
{
const string source = """
using ComputeSharp.D2D1;
[{|CMPSD2D0066:D2DGeneratedPixelShaderDescriptor|}]
internal partial struct MyType
{
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DGeneratedPixelShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidD2DGeneratedPixelShaderDescriptorAttributeTarget_GenericType()
{
const string source = """
using ComputeSharp;
using ComputeSharp.D2D1;
[{|CMPSD2D0066:D2DGeneratedPixelShaderDescriptor|}]
internal partial struct MyType<T> : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DGeneratedPixelShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidD2DGeneratedPixelShaderDescriptorAttributeTarget_TypeNestedInsideGenericType()
{
const string source = """
using ComputeSharp;
using ComputeSharp.D2D1;
internal partial class Foo<T>
{
[{|CMPSD2D0066:D2DGeneratedPixelShaderDescriptor|}]
internal partial struct MyType : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DGeneratedPixelShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
}
+54
ファイルの表示
@@ -337,4 +337,58 @@ public class Test_Analyzers
await CSharpAnalyzerWithLanguageVersionTest<InvalidGroupSharedFieldDeclarationAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidGeneratedComputeShaderDescriptorAttributeTarget_NoInterface()
{
const string source = """
using ComputeSharp;
[{|CMPS0054:GeneratedComputeShaderDescriptor|}]
internal partial struct MyType
{
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidGeneratedComputeShaderDescriptorAttributeTarget_GenericType()
{
const string source = """
using ComputeSharp;
[{|CMPS0054:GeneratedComputeShaderDescriptor|}]
internal partial struct MyType<T> : IComputeShader
{
public void Execute()
{
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task InvalidGeneratedComputeShaderDescriptorAttributeTarget_TypeNestedInsideGenericType()
{
const string source = """
using ComputeSharp;
internal partial class Foo<T>
{
[{|CMPS0054:GeneratedComputeShaderDescriptor|}]
internal partial struct MyType : IComputeShader
{
public void Execute()
{
}
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
}