From a2060a7c45d9034bcf4a8441518a2e794573db3d Mon Sep 17 00:00:00 2001 From: Alex Macocian Date: Mon, 23 Sep 2024 10:59:25 +0200 Subject: [PATCH] Fix empty body methods --- Sybil.IntegrationTests/FlowTests.cs | 8 +++++++- Sybil/MethodBuilder.cs | 1 + Sybil/Sybil.csproj | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sybil.IntegrationTests/FlowTests.cs b/Sybil.IntegrationTests/FlowTests.cs index 206dc76..28b7147 100644 --- a/Sybil.IntegrationTests/FlowTests.cs +++ b/Sybil.IntegrationTests/FlowTests.cs @@ -34,6 +34,8 @@ public sealed class TestClass : BaseTestClass, IInterface where T : new(), cl this.fieldString = 0; return this.fieldString; } + + public string GetSomething(); }"; [TestMethod] @@ -95,7 +97,11 @@ public sealed class TestClass : BaseTestClass, IInterface where T : new(), cl .WithTypeParameter(SyntaxBuilder.CreateTypeParameter("T")) .WithAttribute(SyntaxBuilder.CreateAttribute("SomeAttribute4") .WithArgument(0.5f)) - .WithBody("this.fieldString = 0;\r\nreturn this.fieldString;")))) + .WithBody("this.fieldString = 0;\r\nreturn this.fieldString;")) + .WithMethod( + SyntaxBuilder.CreateMethod("string", "GetSomething") + .WithModifier("public") + .WithNoBody()))) .Build(); var compilationUnit = compilationUnitSyntax.ToFullString(); diff --git a/Sybil/MethodBuilder.cs b/Sybil/MethodBuilder.cs index bf258d3..c115dee 100644 --- a/Sybil/MethodBuilder.cs +++ b/Sybil/MethodBuilder.cs @@ -169,6 +169,7 @@ namespace Sybil } return this.MethodDeclarationSyntax + .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)) .NormalizeWhitespace(); } } diff --git a/Sybil/Sybil.csproj b/Sybil/Sybil.csproj index f599cbc..bb1ea07 100644 --- a/Sybil/Sybil.csproj +++ b/Sybil/Sybil.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 0.8.2 + 0.8.3