Add unit tests for new analyzer
このコミットが含まれているのは:
1 親
e09007e910
コミット
fe0f68d921
3ファイル変更
+130
検索条件に一致するファイルはありません
+5
@@ -5,6 +5,7 @@
|
||||
https://api.nuget.org/v3/index.json;
|
||||
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json;
|
||||
</RestoreSources>
|
||||
<DefineConstants>$(DefineConstants);D2D1_TESTS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -23,4 +24,8 @@
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.CodeFixers\ComputeSharp.D2D1.CodeFixers.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ComputeSharp.Tests.SourceGenerators\Helpers\CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs" Link="Helpers\CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
using System.Threading.Tasks;
|
||||
using ComputeSharp.D2D1.SourceGenerators;
|
||||
using ComputeSharp.Tests.SourceGenerators.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.D2D1.Tests.SourceGenerators;
|
||||
|
||||
[TestClass]
|
||||
public class Test_InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task NoCompileOptionsDoesNotWarn()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class Foo
|
||||
{
|
||||
[D2DInputCount(0)]
|
||||
private partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public Float4 Execute() => 0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task ValidCompileOptionsDoesNotWarn()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class Foo
|
||||
{
|
||||
[D2DInputCount(0)]
|
||||
[D2DCompileOptions(D2D1CompileOptions.PackMatrixRowMajor)]
|
||||
private partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public Float4 Execute() => 0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task EnableLinkingWithNoInputCountDoesNotWarn()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class Foo
|
||||
{
|
||||
[D2DInputComplex(0)]
|
||||
[D2DCompileOptions(D2D1CompileOptions.EnableLinking)]
|
||||
private partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public Float4 Execute() => 0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task EnableLinkingWithImplicitComplexInputWarns()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class Foo
|
||||
{
|
||||
[D2DInputCount(2)]
|
||||
[D2DInputSimple(1)]
|
||||
[{|CMPSD2D0069:D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking)|}]
|
||||
private partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public Float4 Execute() => 0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task EnableLinkingWithExplicitComplexInputWarns()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class Foo
|
||||
{
|
||||
[D2DInputCount(2)]
|
||||
[D2DInputSimple(0)]
|
||||
[D2DInputComplex(1)]
|
||||
[{|CMPSD2D0069:D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking)|}]
|
||||
private partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public Float4 Execute() => 0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2D1CompileOptionsEnableLinkingOnShaderTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
}
|
||||
+8
@@ -1,5 +1,9 @@
|
||||
extern alias Core;
|
||||
#if D2D1_TESTS
|
||||
extern alias D2D1;
|
||||
#else
|
||||
extern alias D3D12;
|
||||
#endif
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -48,7 +52,11 @@ internal sealed class CSharpAnalyzerWithLanguageVersionTest<TAnalyzer> : CSharpA
|
||||
|
||||
test.TestState.ReferenceAssemblies = ReferenceAssemblies.Net.Net80;
|
||||
test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(Core::ComputeSharp.Hlsl).Assembly.Location));
|
||||
#if D2D1_TESTS
|
||||
test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly.Location));
|
||||
#else
|
||||
test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(D3D12::ComputeSharp.IComputeShader).Assembly.Location));
|
||||
#endif
|
||||
|
||||
return test.RunAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする