diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs index 9232e403..79a971ae 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.Helpers.cs @@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator /// Whether or not implements . private static bool IsD2D1PixelShaderType(INamedTypeSymbol typeSymbol, INamedTypeSymbol d2D1PixelShaderSymbol) { - foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.Interfaces) + foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces) { if (interfaceSymbol.Name == nameof(ID2D1PixelShader) && SymbolEqualityComparer.Default.Equals(interfaceSymbol, d2D1PixelShaderSymbol)) diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.Helpers.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.Helpers.cs index 88d0550c..77462b98 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.Helpers.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.Helpers.cs @@ -23,7 +23,7 @@ partial class IShaderGenerator INamedTypeSymbol iComputeShaderSymbol, INamedTypeSymbol iPixelShaderSymbol) { - foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.Interfaces) + foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces) { if (interfaceSymbol.Name == nameof(IComputeShader) && SymbolEqualityComparer.Default.Equals(interfaceSymbol, iComputeShaderSymbol)) diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index 0c497090..3fd445c3 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -272,6 +272,70 @@ namespace ComputeSharp.Tests this.buffer[ThreadIds.X] *= this.number; } } + + [TestMethod] + public void ComputeShaderWithInheritedShaderInterface() + { + _ = ReflectionServices.GetShaderInfo(); + } + + public interface IMyBaseShader : IComputeShader + { + public int A { get; } + + public void B(); + } + + [AutoConstructor] + internal readonly partial struct ComputeShaderWithInheritedShaderInterfaceShader : IMyBaseShader + { + int IMyBaseShader.A { get; } + + void IMyBaseShader.B() + { + } + + public readonly ReadWriteBuffer buffer; + public readonly float number; + + /// + public void Execute() + { + this.buffer[ThreadIds.X] *= this.number; + } + } + + [TestMethod] + public void PixelShaderWithInheritedShaderInterface() + { + _ = ReflectionServices.GetShaderInfo(); + } + + public interface IMyBaseShader : IPixelShader + where T : unmanaged + { + public int A { get; } + + public void B(); + } + + [AutoConstructor] + internal readonly partial struct PixelShaderWithInheritedShaderInterfaceShader : IMyBaseShader + { + int IMyBaseShader.A { get; } + + void IMyBaseShader.B() + { + } + + public readonly float number; + + /// + public float4 Execute() + { + return default; + } + } } }