Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling partial record struct types, add test #589

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ComputeSharp.SourceGeneration/Models/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public string GetTypeKeyword()
{
return Kind switch
{
TypeKind.Struct when IsRecord => "record struct",
TypeKind.Struct => "struct",
TypeKind.Interface => "interface",
TypeKind.Class when IsRecord => "record",
Expand Down
33 changes: 33 additions & 0 deletions tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,4 +975,37 @@ private static void ValidateShadersAreEqual(in ShaderWithScalarVectorAndMatrixTy
Assert.AreEqual(left.container1.i2x2.M22, right.container1.i2x2.M22);
Assert.AreEqual(left.container1.d, right.container1.d);
}

public partial class ContainingClass
{
public partial record ContainingRecord
{
public partial struct ContainingStruct
{
public partial record struct ContainingRecordStruct
{
public partial interface IContainingInterface
{
[D2DInputCount(0)]
[D2DGeneratedPixelShaderDescriptor]
[AutoConstructor]
public readonly partial struct DeeplyNestedShader : ID2D1PixelShader
{
public float4 Execute()
{
return 0;
}
}
}
}
}
}
}

[TestMethod]
public void DeeplyNestedShaderType_VerifyGenerator()
{
// Just a sanity check that the generated code is present
Assert.AreEqual(0, D2D1PixelShader.GetInputCount<ContainingClass.ContainingRecord.ContainingStruct.ContainingRecordStruct.IContainingInterface.DeeplyNestedShader>());
}
}