From b1404e3fa8b4efc7d934539698b00e688e91473b Mon Sep 17 00:00:00 2001 From: Dr_Cox1911 Date: Sun, 6 Feb 2022 21:07:54 +0100 Subject: [PATCH] Bugfix empty body on abstract method --- src/CodeGenHelpers/MethodBuilder.cs | 7 +++++++ .../SampleCode/SampleAbstractMethod.cs | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/CodeGenHelpers/MethodBuilder.cs b/src/CodeGenHelpers/MethodBuilder.cs index 497a41a..5e2b01d 100644 --- a/src/CodeGenHelpers/MethodBuilder.cs +++ b/src/CodeGenHelpers/MethodBuilder.cs @@ -216,6 +216,13 @@ internal override void Write(in CodeWriter writer) foreach (var attribute in _attributes) writer.AppendLine($"[{attribute}]"); + + if (IsAbstract) + { + writer.AppendLine($"{output};"); + return; + } + using (writer.Block(output.Trim(), _generics.Contraints())) { _methodBodyWriter?.Invoke(writer); diff --git a/tests/CodeGenHelpers.Tests/SampleCode/SampleAbstractMethod.cs b/tests/CodeGenHelpers.Tests/SampleCode/SampleAbstractMethod.cs index 9c3bdc6..cb1b63f 100644 --- a/tests/CodeGenHelpers.Tests/SampleCode/SampleAbstractMethod.cs +++ b/tests/CodeGenHelpers.Tests/SampleCode/SampleAbstractMethod.cs @@ -11,8 +11,6 @@ namespace CodeGenHelpers.SampleCode { partial class SampleAbstractMethod { - abstract void MyAbstractMethod() - { - } + abstract void MyAbstractMethod(); } }