Add tests for D2DRuntimeCompilationDisabledAnalyzer

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-16 02:35:24 +01:00
1 親 37af7113e6
コミット f603434310
2ファイル変更
+77

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

+66
ファイルの表示
@@ -196,4 +196,70 @@ public class Test_Analyzers
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DGeneratedPixelShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task ShaderWithNoPrecompiledBytecode_WithNoD2DEnableRuntimeCompilation_Warns()
{
const string source = """
using ComputeSharp;
using ComputeSharp.D2D1;
[D2DInputCount(0)]
[D2DGeneratedPixelShaderDescriptor]
internal partial struct {|CMPSD2D0076:MyType|} : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<D2DRuntimeCompilationDisabledAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task ShaderWithNoPrecompiledBytecode_WithD2DEnableRuntimeCompilation_OnType_DoesNotWarn()
{
const string source = """
using ComputeSharp;
using ComputeSharp.D2D1;
[D2DInputCount(0)]
[D2DGeneratedPixelShaderDescriptor]
[D2DEnableRuntimeCompilation]
internal partial struct MyType : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<D2DRuntimeCompilationDisabledAnalyzer>.VerifyAnalyzerAsync(source);
}
[TestMethod]
public async Task ShaderWithNoPrecompiledBytecode_WithD2DEnableRuntimeCompilation_OnAssembly_DoesNotWarn()
{
const string source = """
using ComputeSharp;
using ComputeSharp.D2D1;
[assembly: D2DEnableRuntimeCompilation]
[D2DInputCount(0)]
[D2DGeneratedPixelShaderDescriptor]
internal partial struct MyType : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
""";
await CSharpAnalyzerWithLanguageVersionTest<D2DRuntimeCompilationDisabledAnalyzer>.VerifyAnalyzerAsync(source);
}
}
@@ -30,6 +30,8 @@ public class Test_D2DPixelShaderSourceGenerator
using float3 = global::ComputeSharp.Float3;
using float4 = global::ComputeSharp.Float4;
[assembly: D2DEnableRuntimeCompilation]
namespace MyNamespace;
[D2DInputCount(0)]
@@ -679,6 +681,8 @@ public class Test_D2DPixelShaderSourceGenerator
using float3 = global::ComputeSharp.Float3;
using float4 = global::ComputeSharp.Float4;
[assembly: D2DEnableRuntimeCompilation]
namespace MyNamespace;
[D2DEffectId("B30E1384-DEE1-4200-9312-321521DF3B00")]
@@ -985,6 +989,8 @@ public class Test_D2DPixelShaderSourceGenerator
using float3 = global::ComputeSharp.Float3;
using float4 = global::ComputeSharp.Float4;
[assembly: D2DEnableRuntimeCompilation]
namespace MyNamespace;
[D2DInputCount(0)]
@@ -1280,6 +1286,8 @@ public class Test_D2DPixelShaderSourceGenerator
using ComputeSharp.D2D1;
using float4 = global::ComputeSharp.Float4;
[assembly: D2DEnableRuntimeCompilation]
namespace MyNamespace;
[D2DInputCount(2)]
@@ -1566,6 +1574,8 @@ public class Test_D2DPixelShaderSourceGenerator
using int2 = global::ComputeSharp.Int2;
using float4 = global::ComputeSharp.Float4;
[assembly: D2DEnableRuntimeCompilation]
namespace MyNamespace;
[D2DInputCount(0)]
@@ -1802,6 +1812,7 @@ public class Test_D2DPixelShaderSourceGenerator
private static async Task VerifyGeneratedDiagnosticsAsync(string source, (string Filename, string Source) result)
{
// Also validate all analyzers
await CSharpAnalyzerWithLanguageVersionTest<D2DRuntimeCompilationDisabledAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidAssemblyLevelCompileOptionsAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DGeneratedPixelShaderDescriptorAttributeTargetAnalyzer>.VerifyAnalyzerAsync(source);