Skip to content

Commit

Permalink
[C#] Fix espace en trop potentiel dans les contrôleurs au début
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Dec 13, 2023
1 parent f347ef6 commit b78f252
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions TopModel.Generator.Csharp/CSharpApiServerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConstructorDeclarationSyntax>().Any())
{
wd.AppendLine();
}

wd.AppendLine();

wd.AppendLine($"{indent}/// <summary>");
wd.AppendLine($"{indent}/// {endpoint.Description}");
Expand Down Expand Up @@ -119,6 +117,11 @@ public class {className} : Controller
}
}

if (controller.OpenBraceToken.HasTrailingTrivia && !controller.Members.OfType<FieldDeclarationSyntax>().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());
}
Expand Down Expand Up @@ -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<IFieldProperty>().Single(param => param.GetParamName() == routeParamName);
Expand Down

0 comments on commit b78f252

Please sign in to comment.