From 409138d01bb2eccb01397fc155458bb779613033 Mon Sep 17 00:00:00 2001 From: colinator27 <17358554+colinator27@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:37:26 -0400 Subject: [PATCH] Fix #7 --- .../Decompiler/AST/Nodes/EnumDeclNode.cs | 4 ++++ ...mpileContext.DecompileToString.Settings.cs | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Underanalyzer/Decompiler/AST/Nodes/EnumDeclNode.cs b/Underanalyzer/Decompiler/AST/Nodes/EnumDeclNode.cs index 1904171..127d964 100644 --- a/Underanalyzer/Decompiler/AST/Nodes/EnumDeclNode.cs +++ b/Underanalyzer/Decompiler/AST/Nodes/EnumDeclNode.cs @@ -34,6 +34,10 @@ public void Print(ASTPrinter printer) { printer.Write("enum "); printer.Write(Enum.Name); + if (printer.Context.Settings.OpenBlockBraceOnSameLine) + { + printer.Write(' '); + } printer.OpenBlock(); // Sort values of enum by value diff --git a/UnderanalyzerTest/DecompileContext.DecompileToString.Settings.cs b/UnderanalyzerTest/DecompileContext.DecompileToString.Settings.cs index 9f39cff..a124d22 100644 --- a/UnderanalyzerTest/DecompileContext.DecompileToString.Settings.cs +++ b/UnderanalyzerTest/DecompileContext.DecompileToString.Settings.cs @@ -1119,4 +1119,27 @@ pop.v.i self.d } ); } + + [Fact] + public void TestEnumOpenBraceSameLine() + { + TestUtil.VerifyDecompileResult( + """ + push.l 0 + pop.v.l self.a + """, + """ + a = UnknownEnum.Value_0; + + enum UnknownEnum { + Value_0 + } + """, + null, + new DecompileSettings() + { + OpenBlockBraceOnSameLine = true + } + ); + } }