From f0acc27098b6c609d9b6e0d3ac3289aaa122eeda Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 17 Aug 2019 23:08:49 +0200 Subject: [PATCH] Fixed indentation in shader source for local methods --- src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs index e42fe85e..2fdc88b4 100644 --- a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs +++ b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs @@ -142,10 +142,11 @@ namespace ComputeSharp.Shaders.Translation EntityHandle methodHandle = MetadataTokenHelpers.TryAsEntityHandle(methodInfo.MetadataToken) ?? throw new InvalidOperationException(); string methodOnlySourceCode = decompiler.DecompileAsString(methodHandle), - methodOnlyFixedSourceCode = LambdaMethodDeclarationRegex.Replace(methodOnlySourceCode, "internal void Main"); + methodOnlyFixedSourceCode = LambdaMethodDeclarationRegex.Replace(methodOnlySourceCode, "internal void Main"), + methodOnlyIndentedSourceCode = $" {methodOnlyFixedSourceCode.Replace(Environment.NewLine, $"{Environment.NewLine} ")}"; int lastClosedBracketsIndex = methodFixedCode.LastIndexOf('}'); - methodFixedCode = methodFixedCode.Insert(lastClosedBracketsIndex, methodOnlyFixedSourceCode); + methodFixedCode = methodFixedCode.Insert(lastClosedBracketsIndex, methodOnlyIndentedSourceCode); } // Load the type syntax tree