diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index 7a50d05..7e06527 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.7.2 + 1.7.3 Logo_Symbol_Black_Outline.png diff --git a/Rest.Net/RestCSharpClientGenerator.cs b/Rest.Net/RestCSharpClientGenerator.cs index 5873498..6b071ca 100644 --- a/Rest.Net/RestCSharpClientGenerator.cs +++ b/Rest.Net/RestCSharpClientGenerator.cs @@ -250,17 +250,20 @@ namespace MontoyaTech.Rest.Net writer.Outdent().WriteLine('}'); //Generate a constructor to set all the fields/properties with optional default values - writer.WriteBreak(); - writer.Write($"public {(newName != null ? newName.Name : type.Name)}("); + if (fields.Length > 0 || properties.Length > 0) + { + writer.WriteBreak(); + writer.Write($"public {(newName != null ? newName.Name : type.Name)}("); - foreach (var field in fields) - writer.WriteSeparator().Write($"{this.GetTypeFullyResolvedName(field.FieldType)} {field.Name} = {this.GetTypeDefaultValue(field.FieldType)}"); + foreach (var field in fields) + writer.WriteSeparator().Write($"{this.GetTypeFullyResolvedName(field.FieldType)} {field.Name} = {this.GetTypeDefaultValue(field.FieldType)}"); - foreach (var property in properties) - writer.WriteSeparator().Write($"{this.GetTypeFullyResolvedName(property.PropertyType)} {property.Name} = {this.GetTypeDefaultValue(property.PropertyType)}"); + foreach (var property in properties) + writer.WriteSeparator().Write($"{this.GetTypeFullyResolvedName(property.PropertyType)} {property.Name} = {this.GetTypeDefaultValue(property.PropertyType)}"); - writer.WriteLine(")"); - writer.WriteLine('{').Indent(); + writer.WriteLine(")"); + writer.WriteLine('{').Indent(); + } foreach (var field in fields) writer.WriteLine($"this.{field.Name} = {field.Name};");