Add tests for missing descriptor attribute code fixer
このコミットが含まれているのは:
1 親
21f410e7c4
コミット
d992600689
2ファイル変更
+184
-1
検索条件に一致するファイルはありません
+6
-1
@@ -7,11 +7,16 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.MSTest" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.MSTest" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" Aliases="Core" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" Aliases="D2D1" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.CodeFixers\ComputeSharp.D2D1.CodeFixers.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
extern alias Core;
|
||||
extern alias D2D1;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.Testing;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using CSharpCodeFixTest = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixTest<
|
||||
ComputeSharp.D2D1.SourceGenerators.MissingPixelShaderDescriptorOnPixelShaderAnalyzer,
|
||||
ComputeSharp.D2D1.CodeFixers.MissingPixelShaderDescriptorOnPixelShaderCodeFixer,
|
||||
Microsoft.CodeAnalysis.Testing.Verifiers.MSTestVerifier>;
|
||||
|
||||
namespace ComputeSharp.D2D1.Tests.SourceGenerators;
|
||||
|
||||
[TestClass]
|
||||
public class Test_MissingPixelShaderDescriptorOnPixelShaderCodeFixer
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task FileContainsComputeSharpD2D1UsingDirective()
|
||||
{
|
||||
string original = """
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
partial struct {|CMPSD2D0065:MyShader|} : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
string @fixed = """
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpCodeFixTest test = new()
|
||||
{
|
||||
TestCode = original,
|
||||
FixedCode = @fixed,
|
||||
ReferenceAssemblies = ReferenceAssemblies.Net.Net60
|
||||
};
|
||||
|
||||
test.TestState.AdditionalReferences.Add(typeof(Core::ComputeSharp.Float4).Assembly);
|
||||
test.TestState.AdditionalReferences.Add(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly);
|
||||
test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", "[*]\nend_of_line = lf"));
|
||||
|
||||
await test.RunAsync();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task FileDoesNotContainComputeSharpD2D1UsingDirective()
|
||||
{
|
||||
string original = """
|
||||
partial struct {|CMPSD2D0065:MyShader|} : ComputeSharp.D2D1.ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
string @fixed = """
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
partial struct MyShader : ComputeSharp.D2D1.ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpCodeFixTest test = new()
|
||||
{
|
||||
TestCode = original,
|
||||
FixedCode = @fixed,
|
||||
ReferenceAssemblies = ReferenceAssemblies.Net.Net60
|
||||
};
|
||||
|
||||
test.TestState.AdditionalReferences.Add(typeof(Core::ComputeSharp.Float4).Assembly);
|
||||
test.TestState.AdditionalReferences.Add(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly);
|
||||
test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", "[*]\nend_of_line = lf"));
|
||||
|
||||
await test.RunAsync();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task InsertsAttributeAfterAllOtherD2DAttributes()
|
||||
{
|
||||
string original = """
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputSimple(0)]
|
||||
partial struct {|CMPSD2D0065:MyShader|} : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
string @fixed = """
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputSimple(0)]
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpCodeFixTest test = new()
|
||||
{
|
||||
TestCode = original,
|
||||
FixedCode = @fixed,
|
||||
ReferenceAssemblies = ReferenceAssemblies.Net.Net60
|
||||
};
|
||||
|
||||
test.TestState.AdditionalReferences.Add(typeof(Core::ComputeSharp.Float4).Assembly);
|
||||
test.TestState.AdditionalReferences.Add(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly);
|
||||
test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", "[*]\nend_of_line = lf"));
|
||||
|
||||
await test.RunAsync();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task InsertsAttributeAfterAllOtherD2DAttributes_WithOtherNonD2DAttribute()
|
||||
{
|
||||
string original = """
|
||||
using System;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputSimple(0)]
|
||||
[Test]
|
||||
partial struct {|CMPSD2D0065:MyShader|} : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
|
||||
public class TestAttribute : Attribute
|
||||
{
|
||||
}
|
||||
""";
|
||||
|
||||
string @fixed = """
|
||||
using System;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
[D2DInputCount(1)]
|
||||
[D2DInputSimple(0)]
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
[Test]
|
||||
partial struct MyShader : ID2D1PixelShader
|
||||
{
|
||||
public ComputeSharp.Float4 Execute() => 0;
|
||||
}
|
||||
|
||||
public class TestAttribute : Attribute
|
||||
{
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpCodeFixTest test = new()
|
||||
{
|
||||
TestCode = original,
|
||||
FixedCode = @fixed,
|
||||
ReferenceAssemblies = ReferenceAssemblies.Net.Net60
|
||||
};
|
||||
|
||||
test.TestState.AdditionalReferences.Add(typeof(Core::ComputeSharp.Float4).Assembly);
|
||||
test.TestState.AdditionalReferences.Add(typeof(D2D1::ComputeSharp.D2D1.ID2D1PixelShader).Assembly);
|
||||
test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", "[*]\nend_of_line = lf"));
|
||||
|
||||
await test.RunAsync();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする