From 19f304f966a46e2f37835223d930eb4435cdfb89 Mon Sep 17 00:00:00 2001 From: Albie Spriddell Date: Mon, 12 Aug 2024 13:58:39 +0100 Subject: [PATCH] add more spacing in generated code --- DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs b/DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs index 6d67aed..1cf8e67 100644 --- a/DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs +++ b/DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs @@ -57,10 +57,11 @@ public static SourceText Build(INamedTypeSymbol classSymbol, RequestSymbolMetada if (buildQueryString) { methodBodyBuilder.AddCode("var uriBuilder = new global::System.Text.StringBuilder(this.RequestPath);").AddEmptyLine(); - methodBodyBuilder.AddCode("var queryBuilder = new global::System.Text.StringBuilder();").AddEmptyLine(); + methodBodyBuilder.AddCode("var queryBuilder = new global::System.Text.StringBuilder();").AddEmptyLine().AddEmptyLine(); WriteUriQueryBuilder(methodBodyBuilder, metadata.Properties[ParameterType.Query].OfType(), "queryBuilder"); + methodBodyBuilder.AddEmptyLine().AddEmptyLine(); methodBodyBuilder.AddCode(new IfBuilder().SetCondition("queryBuilder.Length > 0") .AddCode("queryBuilder.Length--;") .AddCode("uriBuilder.Append(\"?\").Append(queryBuilder);")); @@ -70,7 +71,7 @@ public static SourceText Build(INamedTypeSymbol classSymbol, RequestSymbolMetada // create request body (w/ shortcut to reduce allocations when no query is generated) var uriAccessor = buildQueryString ? "uriBuilder.ToString()" : "this.RequestPath"; - methodBodyBuilder.AddCode($"var request = new global::System.Net.Http.HttpRequestMessage(this.RequestMethod, {uriAccessor});").AddEmptyLine(); + methodBodyBuilder.AddCode($"var request = new global::System.Net.Http.HttpRequestMessage(this.RequestMethod, {uriAccessor});").AddEmptyLine().AddEmptyLine(); // process body content switch (requestBodyType)