diff --git a/TopModel.Generator.Csharp/CSharpApiServerGenerator.cs b/TopModel.Generator.Csharp/CSharpApiServerGenerator.cs index 5e654c6c..ced3dc9a 100644 --- a/TopModel.Generator.Csharp/CSharpApiServerGenerator.cs +++ b/TopModel.Generator.Csharp/CSharpApiServerGenerator.cs @@ -59,10 +59,8 @@ public class {className} : Controller foreach (var endpoint in endpoints) { var wd = new StringBuilder(); - if (endpoints.IndexOf(endpoint) != 0 || controller.DescendantNodes().OfType().Any()) - { - wd.AppendLine(); - } + + wd.AppendLine(); wd.AppendLine($"{indent}/// "); wd.AppendLine($"{indent}/// {endpoint.Description}"); @@ -119,6 +117,11 @@ public class {className} : Controller } } + if (controller.OpenBraceToken.HasTrailingTrivia && !controller.Members.OfType().Any()) + { + controller = controller.WithOpenBraceToken(controller.OpenBraceToken.WithoutTrivia()); + } + using var fw = new FileWriter(filePath, _logger, true) { HeaderMessage = "ATTENTION, CE FICHIER EST PARTIELLEMENT GENERE AUTOMATIQUEMENT !" }; fw.Write(syntaxTree.GetRoot().ReplaceNode(existingController, controller).ToString()); } @@ -152,7 +155,7 @@ private string GetRoute(Endpoint endpoint) for (var i = 0; i < split.Length; i++) { - if (split[i].StartsWith("{")) + if (split[i].StartsWith('{')) { var routeParamName = split[i][1..^1]; var param = endpoint.Params.OfType().Single(param => param.GetParamName() == routeParamName);