Skip to content

Commit

Permalink
add more spacing in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Aug 12, 2024
1 parent 75515a7 commit 19f304f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions DragonFruit.Data.Roslyn/ApiRequestSourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParameterSymbolMetadata>(), "queryBuilder");

methodBodyBuilder.AddEmptyLine().AddEmptyLine();
methodBodyBuilder.AddCode(new IfBuilder().SetCondition("queryBuilder.Length > 0")
.AddCode("queryBuilder.Length--;")
.AddCode("uriBuilder.Append(\"?\").Append(queryBuilder);"));
Expand All @@ -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)
Expand Down

0 comments on commit 19f304f

Please sign in to comment.