Add InvalidD2DPixelShaderSourceMethodReturnTypeAnalyzer tests
このコミットが含まれているのは:
1 親
d90cd39d66
コミット
0b9f9b304e
2ファイル変更
+75
-1
検索条件に一致するファイルはありません
+1
-1
@@ -6,7 +6,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace ComputeSharp.D2D1.Tests.SourceGenerators;
|
||||
|
||||
[TestClass]
|
||||
public class Test_Analyzers
|
||||
public class Test_D2DPixelShaderDescriptorGenerator_Analyzers
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task MissingD2DPixelShaderDescriptor_ComputeShader()
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
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_D2DPixelShaderSourceGenerator_Analyzers
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task InvalidD2DPixelShaderSourceMethodReturnType_ReadOnlySpanOfByte_DoesNotWarn()
|
||||
{
|
||||
const string source = """"
|
||||
using System;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public partial class MyClass
|
||||
{
|
||||
[D2DPixelShaderSource("""
|
||||
#define D2D_INPUT_COUNT 0
|
||||
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(Execute)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
""")]
|
||||
public static partial ReadOnlySpan<byte> InvertEffect();
|
||||
|
||||
public static partial ReadOnlySpan<byte> InvertEffect() => default;
|
||||
}
|
||||
"""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DPixelShaderSourceMethodReturnTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("TimeSpan")]
|
||||
[DataRow("ReadOnlyMemory<byte>")]
|
||||
[DataRow("ReadOnlySpan<int>")]
|
||||
[DataRow("string")]
|
||||
[DataRow("object")]
|
||||
[DataRow("byte")]
|
||||
[DataRow("dynamic")]
|
||||
[DataRow("byte*")]
|
||||
public async Task InvalidD2DPixelShaderSourceMethodReturnType_InvalidType_Warns(string returnType)
|
||||
{
|
||||
string source = $$""""
|
||||
using System;
|
||||
using ComputeSharp.D2D1;
|
||||
|
||||
public unsafe partial class MyClass
|
||||
{
|
||||
[D2DPixelShaderSource("""
|
||||
#define D2D_INPUT_COUNT 0
|
||||
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(Execute)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
""")]
|
||||
public static partial {{returnType}} {|CMPSD2D0057:InvertEffect|}();
|
||||
|
||||
public static partial {{returnType}} InvertEffect() => default;
|
||||
}
|
||||
"""";
|
||||
|
||||
await CSharpAnalyzerWithLanguageVersionTest<InvalidD2DPixelShaderSourceMethodReturnTypeAnalyzer>.VerifyAnalyzerAsync(source);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする