From c3dcaa0e7c4888ca3a14dadd61155a61f43ec597 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 26 Aug 2020 13:39:01 +0200 Subject: [PATCH] Fixed invalid variable names in C#/HLSL --- src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs index 4ff57cfd..abf4038c 100644 --- a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs +++ b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs @@ -218,6 +218,9 @@ namespace ComputeSharp.Shaders.Translation // Replace the discards source = Regex.Replace(source, @"(? $"out {m.Groups[1].Value} {new string(Guid.NewGuid().ToByteArray().Select(b => (char)('a' + b % 26)).ToArray())}"); + // Fix invalid C# names with @ prefix + source = Regex.Replace(source, @"@(\w+)", m => $"__at__{m.Groups[1].Value}"); + // Load the syntax tree and the entry node SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(source); MethodDeclarationSyntax rootNode = syntaxTree