Bumped package version to 1.5.5, added code to the CSharp client generator to generate a empty constructor and a constructor that can take an existing instance of a dto and automatically copy all the values.
This commit is contained in:
parent
5048640a53
commit
5e814e81c6
@ -17,7 +17,7 @@
|
|||||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<Version>1.5.4</Version>
|
<Version>1.5.5</Version>
|
||||||
<PackageReleaseNotes></PackageReleaseNotes>
|
<PackageReleaseNotes></PackageReleaseNotes>
|
||||||
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -218,6 +218,26 @@ namespace MontoyaTech.Rest.Net
|
|||||||
if (!property.IsSpecialName && property.GetSetMethod() != null && property.GetGetMethod() != null)
|
if (!property.IsSpecialName && property.GetSetMethod() != null && property.GetGetMethod() != null)
|
||||||
this.GenerateCSharpIncludedProperty(property, writer);
|
this.GenerateCSharpIncludedProperty(property, writer);
|
||||||
|
|
||||||
|
if (!type.IsEnum)
|
||||||
|
{
|
||||||
|
//Generate an empty constructor
|
||||||
|
writer.WriteBreak();
|
||||||
|
writer.WriteLine($"public {(newName != null ? newName.Name : type.Name)}() {{ }}");
|
||||||
|
|
||||||
|
//Generate a constructor to set all the fields/properties from an existing instance
|
||||||
|
writer.WriteBreak();
|
||||||
|
writer.WriteLine($"public {(newName != null ? newName.Name : type.Name)}({(newName != null ? newName.Name : type.Name)} instance)");
|
||||||
|
writer.WriteLine('{').Indent();
|
||||||
|
|
||||||
|
foreach (var field in fields)
|
||||||
|
writer.WriteLine($"this.{field.Name} = instance.{field.Name};");
|
||||||
|
|
||||||
|
foreach (var property in properties)
|
||||||
|
writer.WriteLine($"this.{property.Name} = instance.{property.Name};");
|
||||||
|
|
||||||
|
writer.Outdent().WriteLine('}');
|
||||||
|
}
|
||||||
|
|
||||||
//Generate C# for any types that belong to this one.
|
//Generate C# for any types that belong to this one.
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
if (types[i].DeclaringType == type)
|
if (types[i].DeclaringType == type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user