From f7d998ef308945071f2a6446a9b2d481c033ae10 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 28 Dec 2020 22:46:33 +0100 Subject: [PATCH] Skipped hashcode providers with no delegates --- .../IComputeShaderHashCodeGenerator.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs b/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs index 9fe81a0f..2632d94f 100644 --- a/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs @@ -4,7 +4,6 @@ using System.Diagnostics.Contracts; using System.Linq; using System.Text; using ComputeSharp.SourceGenerators.Extensions; -using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -41,6 +40,8 @@ namespace ComputeSharp.SourceGenerators TypeSyntax shaderType = ParseTypeName(structDeclarationSymbol.ToDisplayString()); BlockSyntax block = Block(GetDelegateHashCodeStatements(structDeclarationSymbol)); + if (block.Statements.Count == 1) continue; + // Create a static method to create the combined hashcode for a given shader type. // This code takes a block syntax and produces a compilation unit as follows: // @@ -106,15 +107,11 @@ namespace ComputeSharp.SourceGenerators if (typeSymbol.TypeKind != TypeKind.Delegate) continue; - _ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping); - - string fieldName = mapping ?? fieldSymbol.Name; - // hash += hash << 5; yield return ExpressionStatement(ParseExpression($"hash += hash << 5")); // hash += shader.Field[#i].Method.GetHashCode(); - yield return ExpressionStatement(ParseExpression($"hash += shader.{fieldName}.Method.GetHashCode()")); + yield return ExpressionStatement(ParseExpression($"hash += shader.{fieldSymbol.Name}.Method.GetHashCode()")); } yield return ReturnStatement(IdentifierName("hash"));