From 3bf77618e46bad9eb39e45b83c0f6d347d057f57 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 27 Apr 2022 22:38:50 +0200 Subject: [PATCH] Exclude explicit interface implementations in shaders --- ...2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs | 12 ++++++++++++ .../IShaderGenerator.CreateBuildHlslSourceMethod.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index f68e444d..36842aac 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -240,6 +240,12 @@ partial class ID2D1ShaderGenerator methodDeclarationSymbol.TypeParameters.Length == 0 && methodDeclarationSymbol.Parameters.Length == 0; + // Except for the entry point, ignore explicit interface implementations + if (!isShaderEntryPoint && !methodDeclarationSymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) + { + continue; + } + // Create the source rewriter for the current method ShaderSourceRewriter shaderSourceRewriter = new( structDeclarationSymbol, @@ -374,6 +380,12 @@ partial class ID2D1ShaderGenerator { foreach (var propertySymbol in structDeclarationSymbol.GetMembers().OfType()) { + // Ignore explicit interface implementations + if (!propertySymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) + { + return; + } + diagnostics.Add(DiagnosticDescriptors.PropertyDeclaration, propertySymbol); } } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index 3e35ad4b..bfb74874 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -354,6 +354,12 @@ partial class IShaderGenerator methodDeclarationSymbol.TypeParameters.Length == 0 && methodDeclarationSymbol.Parameters.Length == 0); + // Except for the entry point, ignore explicit interface implementations + if (!isShaderEntryPoint && !methodDeclarationSymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) + { + continue; + } + // Create the source rewriter for the current method ShaderSourceRewriter shaderSourceRewriter = new( structDeclarationSymbol, @@ -495,6 +501,12 @@ partial class IShaderGenerator { foreach (var propertySymbol in structDeclarationSymbol.GetMembers().OfType()) { + // Ignore explicit interface implementations + if (!propertySymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty) + { + return; + } + diagnostics.Add(DiagnosticDescriptors.PropertyDeclaration, propertySymbol); } }