Skipped fixed buffer fields from auto constructor and data loader
このコミットが含まれているのは:
1 親
c32dc1f579
コミット
33c1415f2d
4ファイル変更
+57
-2
検索条件に一致するファイルはありません
@@ -64,7 +64,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
var structModifiers = structDeclaration.Modifiers;
|
||||
var fields = (
|
||||
from fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>()
|
||||
where !fieldSymbol.IsConst && !fieldSymbol.IsStatic
|
||||
where !fieldSymbol.IsConst && !fieldSymbol.IsStatic && !fieldSymbol.IsFixedSizeBuffer
|
||||
let typeName = fieldSymbol.Type!.ToDisplayString()
|
||||
let fieldFullType = ParseTypeName(typeName)
|
||||
select (Type: fieldFullType, Identifier: Identifier(fieldSymbol.Name))).ToImmutableArray();
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
IFieldSymbol fieldSymbol in
|
||||
from fieldSymbol in currentTypeSymbol.GetMembers().OfType<IFieldSymbol>()
|
||||
where fieldSymbol.Type is INamedTypeSymbol { IsStatic: false } &&
|
||||
!fieldSymbol.IsConst && !fieldSymbol.IsStatic
|
||||
!fieldSymbol.IsConst && !fieldSymbol.IsStatic && !fieldSymbol.IsFixedSizeBuffer
|
||||
select fieldSymbol)
|
||||
{
|
||||
string typeName = fieldSymbol.Type.GetFullMetadataName();
|
||||
|
||||
@@ -38,6 +38,31 @@ namespace ComputeSharp.Tests.SourceGenerators
|
||||
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, "CMPS0001");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void InvalidShaderFixedField()
|
||||
{
|
||||
string source = @"
|
||||
using ComputeSharp;
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
public class ReadWriteBuffer<T> { }
|
||||
}
|
||||
|
||||
namespace MyFancyApp.Sample
|
||||
{
|
||||
public unsafe struct MyShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> buffer;
|
||||
public fixed int text[16];
|
||||
|
||||
public void Execute() { }
|
||||
}
|
||||
}";
|
||||
|
||||
VerifyGeneratedDiagnostics<IComputeShaderSourceGenerator>(source, "CMPS0001");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void InvalidGroupSharedFieldType()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.Tests
|
||||
{
|
||||
[TestClass]
|
||||
[TestCategory("AutoConstructorAttribute")]
|
||||
public unsafe partial class AutoConstructorAttributeTests
|
||||
{
|
||||
[AutoConstructor]
|
||||
public partial struct StructWithFixedField
|
||||
{
|
||||
public int a;
|
||||
public float b;
|
||||
public byte* c;
|
||||
public fixed byte d[16];
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GenerateConstructorWithInheritedUnsafeContextAndIgnoredFixedField()
|
||||
{
|
||||
byte c = 123;
|
||||
|
||||
StructWithFixedField instance = new(42, 3.14f, &c);
|
||||
|
||||
Assert.AreEqual(instance.a, 42);
|
||||
Assert.AreEqual(instance.b, 3.14f);
|
||||
Assert.IsTrue(instance.c == &c);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする