From 4c686139139f5d6d153543a1112771ef9c5050fc Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Tue, 18 Oct 2016 21:30:47 +0100
Subject: [PATCH] Implement public auto properties & update Help.md.

---
 cscz/ClassGenerator.cs | 57 ++++++++++++++++++------------------------
 cscz/Help.md           |  7 +++---
 2 files changed, 28 insertions(+), 36 deletions(-)

diff --git a/cscz/ClassGenerator.cs b/cscz/ClassGenerator.cs
index 3e63f0d..191a916 100644
--- a/cscz/ClassGenerator.cs
+++ b/cscz/ClassGenerator.cs
@@ -48,21 +48,6 @@ namespace cscz
 
 		public GenerationMode GenerationMode = GenerationMode.PublicVariables;
 
-		/// <summary>
-		/// Whether to make data members private and create public properties for them instead of making the
-		/// data members public.
-		/// This is read only. Please refer to GenerationMode in order to change this field.
-		/// </summary>
-		public bool CreateProperties
-		{
-			get
-			{
-				if (GenerationMode == GenerationMode.PrivateVariablesWithProperties)
-					return true;
-				return false;
-			}
-		}
-
 		public ClassGenerator ()
 		{
 		}
@@ -134,26 +119,32 @@ namespace cscz
 
 				constructorSignature.AppendFormat("{0} in{1}, ", datatypeName, publicDataMemberName);
 
-				if (CreateProperties)
+				switch(GenerationMode)
 				{
-					// Private data member
-					classCode.WriteLine("\tprivate {0} {1};", datatypeName, privateDataMemberName);
+					case GenerationMode.PrivateVariablesWithProperties:
+						// Private data member
+						classCode.WriteLine("\tprivate {0} {1};", datatypeName, privateDataMemberName);
+						
+						// Public property associated with above private data member
+						properties.WriteLine("\tpublic {0} {1}", datatypeName, publicDataMemberName);
+						properties.WriteLine("\t{");
+						properties.WriteLine("\t\tget {{ return {0}; }}", privateDataMemberName);
+						properties.WriteLine("\t\tset {{ {0} = value; }}", privateDataMemberName);
+						properties.WriteLine("\t}");
+						
+						// Constructor body
+						constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
+						break;
+					case GenerationMode.PublicAutoProperties:
+						properties.WriteLine("\tpublic {0} {1} {{ get; set; }}", datatypeName, publicDataMemberName);
 
-					// Public property associated with above private data member
-					properties.WriteLine("\tpublic {0} {1}", datatypeName, publicDataMemberName);
-					properties.WriteLine("\t{");
-					properties.WriteLine("\t\tget {{ return {0}; }}", privateDataMemberName);
-					properties.WriteLine("\t\tset {{ {0} = value; }}", privateDataMemberName);
-					properties.WriteLine("\t}");
-
-					// Constructor body
-					constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
-				}
-				else
-				{
-					// Constuctor body
-					classCode.WriteLine("\tpublic {0} {1};", datatypeName, publicDataMemberName);
-					constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
+						constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
+						break;
+					case GenerationMode.PublicVariables:
+						// Constuctor body
+						classCode.WriteLine("\tpublic {0} {1};", datatypeName, publicDataMemberName);
+						constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
+						break;
 				}
 			}
 
diff --git a/cscz/Help.md b/cscz/Help.md
index 545d9f9..854c58e 100644
--- a/cscz/Help.md
+++ b/cscz/Help.md
@@ -7,10 +7,11 @@ Usage:
 
 Options:
 
-Argument	Meaning
+Argument		Meaning
 -------------------------------------------------------------------------------
---public	Causes the parameters of the class to be defined as public data members. This is the default.
---private	Causes the parameters of the class to be defined as private data members with public accessors.
+--public		Generates public data members for the class fields. This is the default.
+--private		Generates private data members with public accessors for the class fields.
+--public-auto	Generates public auto properties for the class fields.
 
 Note that arguments specified later always override arguments specified earlier.
 
