Removed repeated code.

Removed repeated code.

--- src/Tools/RPCGen/Generator.cs
+++ src/Tools/RPCGen/Generator.cs
@@ -197,7 +197,7 @@
             }
             else
             {
-                var typeString = ConvertToTypeString(retType);
+                var typeString = PrettyName(retType);
                 Write("async Task<{0}> {1}.{2}(", typeString, type.Name,
                     method.Name);
             }
@@ -685,9 +685,7 @@
                 case TType.Array:
                 case TType.List:
                 case TType.Map:
-                case TType.Set:
                 case TType.String:
-                case TType.Collection:
                 case TType.Class:
                     return true;
                 default:
@@ -787,7 +785,7 @@

                 WriteLine("field.ClassName = {0};", className);
                 WriteLine("oprot.WriteFieldBegin(field);");
-                GenerateFieldSerialize(param);
+                GenerateTypeSerialization(param.ParameterType, ToTitleCase(param.Name));

                 WriteLine("oprot.WriteFieldEnd();");

@@ -841,7 +839,7 @@
                 WriteLine("if (field.Type == TType.{0})", typeName.ToString());
                 WriteStartBraceIndent();

-                GenerateFieldDeserialize(param);
+                GenerateTypeDeserialization(param.ParameterType, ToTitleCase(param.Name));

                 if (Metadata.IsRequired(param.GetType()))
                     WriteLine("isset_{0} = true;", param.Name);
@@ -885,252 +883,27 @@
         #region Serialization

         /// <summary>
-        /// Generates the code to serialize a field
-        /// </summary>
-        private void GenerateFieldSerialize(Parameter param)
-        {
-            var type = param.ParameterType;
-            var thriftType = ConvertFromTypeToThrift(param.ParameterType);
+        /// Generates the code to serialize a type
+        /// </summary>
+        private void GenerateTypeSerialization(Type type, string name)
+        {
+            var thriftType = ConvertFromTypeToThrift(type);

             switch (thriftType)
             {
-                case TType.Void:
-                    throw new NotSupportedException();
+                case TType.Array:
+                    GenerateArraySerialize(type, name);
+                    break;
+                case TType.List:
+                    GenerateListSerialize(type, name);
+                    break;
+                case TType.Map:
+                    GenerateMapSerialize(type, name);
+                    break;
                 case TType.Struct:
                 case TType.Exception:
-                    GenerateStructSerialize(param);
-                    break;
                 case TType.Class:
-                    GenerateStructSerialize(param);
-                    break;
-                case TType.Array:
-                    GenerateArraySerialize(param);
-                    break;
-                case TType.List:
-                case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                    GenerateContainerSerialize(param);
-                    break;
-                case TType.Bool:
-                case TType.Byte:
-                case TType.Double:
-                case TType.I16:
-                case TType.I32:
-                case TType.I64:
-                case TType.String:
-                    Write("oprot.Write{0}(", thriftType.ToString());
-                    if (type.IsEnum)
-                        Write("({0})", Enum.GetUnderlyingType(type).ToString());
-                    WriteLine("_{0});", param.Name);
-                    break;
-                case TType.Guid:
-                    WriteLine("oprot.WriteString(_{0}.ToString());", param.Name);
-                    break;
-                case TType.DateTime:
-                    WriteLine("oprot.WriteI64(_{0}.Ticks);", param.Name);
-                    break;
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        /// <summary>
-        /// Generates the code to serialize an array
-        /// </summary>
-        private void GenerateArraySerialize(Parameter param)
-        {
-            var paramType = param.ParameterType;
-            var arrayElemType = paramType.GetElementType();
-
-            WriteLine("oprot.WriteArrayBegin(new TArray(TType.{0}, {1}.Length));",
-                      ConvertFromTypeToThrift(paramType).ToString(),
-                      ToTitleCase(param.Name));
-
-            var iterName = string.Format("_iter{0}", GenericIndex++);
-            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(param.Name));
-            WriteStartBraceIndent();
-
-            GenerateContainerSingleElementSerialization(arrayElemType, iterName);
-
-            WriteCloseBraceIndent();
-
-            WriteLine("oprot.WriteArrayEnd();");
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a field of type struct
-        /// </summary>
-        private void GenerateStructSerialize(Parameter param)
-        {
-            var objName = ToTitleCase(param.Name);
-            GenerateStructSerialize(param.ParameterType, objName);
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a field of type struct
-        /// </summary>
-        private void GenerateStructSerialize(Type type, string varName)
-        {
-            var implObjName = varName + "Impl";
-            WriteLine("var {0} = new {1}Impl();", implObjName, type.Name);
-            GenerateStructInit(type, varName, implObjName, true);
-            WriteLine("{0}.Write(oprot);", implObjName);
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a field of type struct
-        /// </summary>
-        private void GenerateStructInit(Type type, string origObjName, string destObjName, bool destTitleCase = true)
-        {
-            foreach (var field in GetAllFields(type))
-            {
-                if (!Metadata.HasId(field))
-                    continue;
-
-                var destName = (destTitleCase)? ToTitleCase(field.Name) : field.Name;
-                var origName = (!destTitleCase)? ToTitleCase(field.Name) : field.Name;
-                WriteLine("{0}.{1} = {2}.{3};", destObjName, destName, origObjName, origName);
-            }
-            foreach (var property in GetAllProperties(type))
-            {
-                if (!Metadata.HasId(property))
-                    continue;
-
-                var destName = (destTitleCase)? ToTitleCase(property.Name) : property.Name;
-                var origName = (!destTitleCase)? ToTitleCase(property.Name) : property.Name;
-                 WriteLine("{0}.{1} = {2}.{3};", destObjName, destName, origObjName, origName);
-            }
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a container field
-        /// </summary>
-        private void GenerateContainerSerialize(Parameter param)
-        {
-            var type = param.ParameterType;
-            var thriftType = ConvertFromTypeToThrift(param.ParameterType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                    GenerateListSerialize(param);
-                    break;
-                case TType.Map:
-                    GenerateMapSerialize(param);
-                    break;
-                case TType.Set:
-                    GenerateSetSerialize(param);
-                    break;
-                case TType.Collection:
-                    GenerateCollectionSerialize(param);
-                    break;
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a list
-        /// </summary>
-        private void GenerateListSerialize(Parameter param)
-        {
-            var paramType = param.ParameterType;
-            var listElemType = param.ParameterType.GetGenericArguments()[0];
-
-            WriteLine("oprot.WriteListBegin(new TList(TType.{0}, {1}.Count));",
-                      ConvertFromTypeToThrift(paramType).ToString(),
-                      ToTitleCase(param.Name));
-
-            var iterName = string.Format("_iter{0}", GenericIndex++);
-            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(param.Name));
-            WriteStartBraceIndent();
-
-            GenerateContainerSingleElementSerialization(listElemType, iterName);
-
-            WriteCloseBraceIndent();
-
-            WriteLine("oprot.WriteListEnd();");
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a collection
-        /// </summary>
-        private void GenerateCollectionSerialize(Parameter param)
-        {
-            GenerateListSerialize(param);
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a set
-        /// </summary>
-        private void GenerateSetSerialize(Parameter param)
-        {
-            var paramType = param.ParameterType;
-            var setElemType = param.ParameterType.GetGenericArguments()[0];
-
-            WriteLine("oprot.WriteSetBegin(new TSet(TType.{0}, {1}.Count));",
-                      ConvertFromTypeToThrift(paramType).ToString(),
-                      ToTitleCase(param.Name));
-
-            var iterName = string.Format("_iter{0}", GenericIndex++);
-            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(param.Name));
-            WriteStartBraceIndent();
-
-            GenerateContainerSingleElementSerialization(setElemType, iterName);
-
-            WriteCloseBraceIndent();
-
-            WriteLine("oprot.WriteSetEnd();");
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a map
-        /// </summary>
-        private void GenerateMapSerialize(Parameter param)
-        {
-            var paramType = param.ParameterType;
-            var mapElemType1 = param.ParameterType.GetGenericArguments()[0];
-            var mapElemType2 = param.ParameterType.GetGenericArguments()[1];
-
-            WriteLine("oprot.WriteMapBegin(new TMap(TType.{0}, TType.{1}, {2}.Count));",
-                      ConvertFromTypeToThrift(mapElemType1).ToString(),
-                      ConvertFromTypeToThrift(mapElemType2).ToString(),
-                      ToTitleCase(param.Name));
-
-            var iterName = string.Format("_iter{0}", GenericIndex++);
-            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(param.Name));
-            WriteStartBraceIndent();
-
-            GenerateContainerDoubleElementSerialization(mapElemType1, mapElemType2, iterName);
-
-            WriteCloseBraceIndent();
-
-            WriteLine("oprot.WriteMapEnd();");
-
-        }
-
-        /// <summary>
-        /// Generates the code to serialize a container element
-        /// </summary>
-        private void GenerateContainerSingleElementSerialization(Type elemType, string iterName)
-        {
-            var thriftType = ConvertFromTypeToThrift(elemType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                case TType.Void:
-                    throw new NotSupportedException();
-                case TType.Struct:
-                case TType.Exception:
-                    GenerateStructSerialize(elemType, iterName);
-                    break;
-                case TType.Class:
-                    GenerateStructSerialize(elemType, iterName);
+                    GenerateStructSerialize(type, name);
                     break;
                 case TType.Bool:
                 case TType.Byte:
@@ -1140,29 +913,147 @@
                 case TType.I64:
                 case TType.String:
                     var enumCast = "";
-                    if (elemType.IsEnum)
-                        enumCast = String.Format("({0})", Enum.GetUnderlyingType(elemType).ToString());
-                    WriteLine("oprot.Write{0}({1}{2});", thriftType.ToString(), enumCast, iterName);
+                    if (type.IsEnum)
+                        enumCast = String.Format("({0})", Enum.GetUnderlyingType(type).ToString());
+                    WriteLine("oprot.Write{0}({1}{2});", thriftType.ToString(), enumCast, name);
                     break;
                 case TType.Guid:
-                    WriteLine("oprot.WriteString({0}.ToString());", iterName);
+                    WriteLine("oprot.WriteString({0}.ToString());", name);
                     break;
                 case TType.DateTime:
-                    WriteLine("oprot.WriteI64({0}.Ticks);", iterName);
+                    WriteLine("oprot.WriteI64({0}.Ticks);", name);
                     break;
+                case TType.Void:
                 default:
+                    System.Diagnostics.Debugger.Break();
                     throw new NotImplementedException();
             }

         }

         /// <summary>
+        /// Generates the code to serialize an array
+        /// </summary>
+        private void GenerateArraySerialize(Type type, string name)
+        {
+            var arrayElemType = type.GetElementType();
+
+            WriteLine("oprot.WriteArrayBegin(new TArray(TType.{0}, {1}.Length));",
+                      ConvertFromTypeToThrift(type).ToString(),
+                      ToTitleCase(name));
+
+            var iterName = string.Format("_iter{0}", GenericIndex++);
+            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(name));
+            WriteStartBraceIndent();
+
+            GenerateTypeSerialization(arrayElemType, iterName);
+
+            WriteCloseBraceIndent();
+
+            WriteLine("oprot.WriteArrayEnd();");
+        }
+
+        /// <summary>
+        /// Generates the code to serialize a field of type struct
+        /// </summary>
+        private void GenerateStructSerialize(Parameter param)
+        {
+            var objName = ToTitleCase(param.Name);
+            GenerateStructSerialize(param.ParameterType, objName);
+        }
+
+        /// <summary>
+        /// Generates the code to serialize a field of type struct
+        /// </summary>
+        private void GenerateStructSerialize(Type type, string varName)
+        {
+            var implObjName = varName + "Impl";
+            implObjName = implObjName.Replace(".", "");
+
+            WriteLine("var {0} = new {1}Impl();", implObjName, type.Name);
+            GenerateStructInit(type, varName, implObjName, true);
+            WriteLine("{0}.Write(oprot);", implObjName);
+        }
+
+        /// <summary>
+        /// Generates the code to serialize a field of type struct
+        /// </summary>
+        private void GenerateStructInit(Type type, string origObjName, string destObjName, bool destTitleCase = true)
+        {
+            foreach (var field in GetAllFields(type))
+            {
+                if (!Metadata.HasId(field))
+                    continue;
+
+                var destName = (destTitleCase)? ToTitleCase(field.Name) : field.Name;
+                var origName = (!destTitleCase)? ToTitleCase(field.Name) : field.Name;
+                WriteLine("{0}.{1} = {2}.{3};", destObjName, destName, origObjName, origName);
+            }
+            foreach (var property in GetAllProperties(type))
+            {
+                if (!Metadata.HasId(property))
+                    continue;
+
+                var destName = (destTitleCase)? ToTitleCase(property.Name) : property.Name;
+                var origName = (!destTitleCase)? ToTitleCase(property.Name) : property.Name;
+                 WriteLine("{0}.{1} = {2}.{3};", destObjName, destName, origObjName, origName);
+            }
+        }
+
+        /// <summary>
+        /// Generates the code to serialize a list
+        /// </summary>
+        private void GenerateListSerialize(Type type, string name)
+        {
+            var listElemType = type.GetGenericArguments()[0];
+
+            WriteLine("oprot.WriteListBegin(new TList(TType.{0}, {1}.Count));",
+                      ConvertFromTypeToThrift(type).ToString(),
+                      ToTitleCase(name));
+
+            var iterName = string.Format("_iter{0}", GenericIndex++);
+            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(name));
+            WriteStartBraceIndent();
+
+            GenerateTypeSerialization(listElemType, iterName);
+
+            WriteCloseBraceIndent();
+
+            WriteLine("oprot.WriteListEnd();");
+        }
+
+        /// <summary>
+        /// Generates the code to serialize a map
+        /// </summary>
+        private void GenerateMapSerialize(Type type, string name)
+        {
+            var mapElemType1 = type.GetGenericArguments()[0];
+            var mapElemType2 = type.GetGenericArguments()[1];
+
+            WriteLine("oprot.WriteMapBegin(new TMap(TType.{0}, TType.{1}, {2}.Count));",
+                      ConvertFromTypeToThrift(mapElemType1).ToString(),
+                      ConvertFromTypeToThrift(mapElemType2).ToString(),
+                      ToTitleCase(name));
+
+            var iterName = string.Format("_iter{0}", GenericIndex++);
+            WriteLine("foreach (var {0} in {1})", iterName, ToTitleCase(name));
+            WriteStartBraceIndent();
+
+            GenerateContainerDoubleElementSerialization(mapElemType1, mapElemType2, iterName);
+
+            WriteCloseBraceIndent();
+
+            WriteLine("oprot.WriteMapEnd();");
+
+        }
+
+        /// <summary>
         /// Generates the code to serialize a dual element container
         /// </summary>
         private void GenerateContainerDoubleElementSerialization(Type elemType1, Type elemType2, string iterName)
         {
-            GenerateContainerSingleElementSerialization(elemType1, iterName + ".Key");
-            GenerateContainerSingleElementSerialization(elemType2, iterName + ".Value");
+            GenerateTypeSerialization(elemType1, iterName + ".Key");
+            GenerateTypeSerialization(elemType2, iterName + ".Value");
         }

         #endregion
@@ -1170,113 +1061,38 @@
         #region Deserialization

         /// <summary>
-        /// Generates the code to deserialize a field
-        /// </summary>
-        private void GenerateFieldDeserialize(Parameter param)
-        {
-            var type = param.ParameterType;
-            var thriftType = ConvertFromTypeToThrift(param.ParameterType);
+        /// Generates the code to deserialize a single element of an array
+        /// </summary>
+        private void GenerateTypeDeserialization(Type type, string name, bool varExists = true)
+        {
+
+            var elemName = string.Format("_elem{0}", GenericIndex++);
+
+            var thriftType = ConvertFromTypeToThrift(type);

             switch (thriftType)
             {
-                case TType.Void:
-                    throw new NotSupportedException();
-                case TType.Struct:
-                case TType.Exception:
-                    GenerateStructDeserialize(param);
-                    break;
-                case TType.Class:
-                    GenerateStructDeserialize(param);
-                    break;
                 case TType.Array:
-                    GenerateArrayDeserialize(param);
+                    GenerateArrayDeserialize(type, name);
                     break;
                 case TType.List:
+                    GenerateListDeserialize(type, name);
+                    break;
                 case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                    GenerateContainerDeserialize(param);
+                    GenerateMapDeserialize(type, name);
                     break;
-                case TType.Bool:
-                case TType.Byte:
-                case TType.Double:
-                case TType.I16:
-                case TType.I32:
-                case TType.I64:
-                case TType.String:
-                    Write("{0} = ", ToTitleCase(param.Name));
-                    // If it is an enum, then we need to cast the value.
-                    if (type.IsValueType && !type.IsPrimitive)
-                        Write("({0}) ", type.FullName);
-                    WriteLine("iprot.Read{0}();", thriftType.ToString());
-                    break;
-                case TType.Guid:
-                    Write("{0} = ", ToTitleCase(param.Name));
-                    WriteLine("new Guid(iprot.ReadString());");
-                    break;
-                case TType.DateTime:
-                    Write("{0} = ", ToTitleCase(param.Name));
-                    WriteLine("new DateTime(iprot.ReadI64());");
-                    break;
-
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        /// <summary>
-        /// Generates the code to deserialize an array
-        /// </summary>
-        private void GenerateArrayDeserialize(Parameter param)
-        {
-            var arrayElemType = param.ParameterType.GetElementType();
-
-            var arrayName = string.Format("_array{0}", GenericIndex++);
-            WriteLine("var {0} = iprot.ReadArrayBegin();", arrayName);
-
-            WriteLine("{0} = new {1}[{2}.Count];", ToTitleCase(param.Name),
-                      ConvertToTypeString(arrayElemType), arrayName);
-
-            var iterName = string.Format("_i{0}", GenericIndex++);
-            WriteLine("for (var {0} = 0; {0} < {1}.Count; ++{0})",
-                      iterName, arrayName);
-
-            WriteStartBraceIndent();
-
-            GenerateArraySingleElementDeserialization(arrayElemType, ToTitleCase(param.Name), iterName);
-
-            WriteCloseBraceIndent();
-            WriteLine("iprot.ReadArrayEnd();");
-        }
-
-        /// <summary>
-        /// Generates the code to deserialize a single element of an array
-        /// </summary>
-        private void GenerateArraySingleElementDeserialization(Type elemType, string containerName, string iterName)
-        {
-
-            var elemName = string.Format("_elem{0}", GenericIndex++);
-
-            var thriftType = ConvertFromTypeToThrift(elemType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                case TType.Void:
-                    throw new NotSupportedException();
                 case TType.Struct:
                 case TType.Exception:
                 case TType.Class:
-                    WriteLine("var {0} = new {1}Impl();", elemName, elemType.Name);
+                    WriteLine("var {0} = new {1}Impl();", elemName, type.Name);
                     WriteLine("{0}.Read(iprot);", elemName);

                     var elemName2 = string.Format("_elem{0}", GenericIndex++);
-                    WriteLine("var {0} = new {1}();", elemName2, elemType.FullName);
-                    GenerateStructInit(elemType, elemName ,elemName2);
-                    WriteLine("{0}[{1}] = {2};", containerName, iterName, elemName2);
+                    WriteLine("var {0} = new {1}();", elemName2, type.FullName);
+                    GenerateStructInit(type, elemName, elemName2);
+                    if (!varExists)
+                        Write("var ");
+                    WriteLine("{0} = {1};", name, elemName2);
                     break;
                 case TType.Bool:
                 case TType.Byte:
@@ -1286,16 +1102,23 @@
                 case TType.I64:
                 case TType.String:
                     var enumCast = "";
-                    if (elemType.IsEnum)
-                        enumCast = String.Format("({0})", elemType.FullName);
-                    WriteLine("{0}[{1}] = {2}iprot.Read{3}();", containerName, iterName, enumCast, thriftType.ToString());
+                    if (type.IsEnum)
+                        enumCast = String.Format("({0})", type.FullName);
+                    if (!varExists)
+                        Write("var ");
+                    WriteLine("{0} = {1}iprot.Read{2}();", name, enumCast, thriftType.ToString());
                     break;
                 case TType.Guid:
-                    WriteLine("{0}[{1}] = new System.Guid(iprot.ReadString());", containerName, iterName);
+                    if (!varExists)
+                        Write("var ");
+                    WriteLine("{0} = new System.Guid(iprot.ReadString());", name);
                     break;
                 case TType.DateTime:
-                    WriteLine("{0}[{1}] = new System.DateTime(iprot.ReadI64());", containerName, iterName);
+                    if (!varExists)
+                        Write("var ");
+                    WriteLine("{0} = new System.DateTime(iprot.ReadI64());", name);
                     break;
+                case TType.Void:
                 default:
                     throw new NotImplementedException();
             }
@@ -1303,11 +1126,28 @@
         }

         /// <summary>
-        /// Generates the code to deserialize a field of type struct
-        /// </summary>
-        private void GenerateStructDeserialize(Parameter param)
-        {
-            GenerateStructDeserialize(param.ParameterType, ToTitleCase(param.Name));
+        /// Generates the code to deserialize an array
+        /// </summary>
+        private void GenerateArrayDeserialize(Type type, string name)
+        {
+            var arrayElemType = type.GetElementType();
+
+            var arrayName = string.Format("_array{0}", GenericIndex++);
+            WriteLine("var {0} = iprot.ReadArrayBegin();", arrayName);
+
+            WriteLine("{0} = new {1}[{2}.Count];", ToTitleCase(name),
+                      ConvertToTypeString(arrayElemType), arrayName);
+
+            var iterName = string.Format("_i{0}", GenericIndex++);
+            WriteLine("for (var {0} = 0; {0} < {1}.Count; ++{0})",
+                      iterName, arrayName);
+
+            WriteStartBraceIndent();
+
+            GenerateTypeDeserialization(arrayElemType, ToTitleCase(name) + "[" + iterName + "]");
+
+            WriteCloseBraceIndent();
+            WriteLine("iprot.ReadArrayEnd();");
         }

         /// <summary>
@@ -1327,41 +1167,14 @@
         }

         /// <summary>
-        /// Generates the code to deserialize a container field
-        /// </summary>
-        private void GenerateContainerDeserialize(Parameter param)
-        {
-            var type = param.ParameterType;
-            var thriftType = ConvertFromTypeToThrift(param.ParameterType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                    GenerateListDeserialize(param);
-                    break;
-                case TType.Map:
-                    GenerateMapDeserialize(param);
-                    break;
-                case TType.Set:
-                    GenerateSetDeserialize(param);
-                    break;
-                case TType.Collection:
-                    GenerateCollectionDeserialize(param);
-                    break;
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        /// <summary>
         /// Generates the code to deserialize a list
         /// </summary>
-        private void GenerateListDeserialize(Parameter param)
-        {
-            var listElemType = param.ParameterType.GetGenericArguments()[0];
-
-            WriteLine("{0} = new List<{1}>();", ToTitleCase(param.Name),
-                      ConvertToGenericArgsString(param.ParameterType));
+        private void GenerateListDeserialize(Type type, string name)
+        {
+            var listElemType = type.GetGenericArguments()[0];
+
+            WriteLine("{0} = new List<{1}>();", ToTitleCase(name),
+                      ConvertToGenericArgsString(type));

             var listName = string.Format("_list{0}", GenericIndex++);
             WriteLine("var {0} = iprot.ReadListBegin();", listName);
@@ -1372,55 +1185,25 @@

             WriteStartBraceIndent();

-            GenerateContainerSingleElementDeserialization(listElemType, ToTitleCase(param.Name));
+            var elemName = string.Format("_elem{0}", GenericIndex++);
+
+            GenerateTypeDeserialization(listElemType, elemName, false);
+            WriteLine("{0}.Add({1});", name, elemName);

             WriteCloseBraceIndent();
             WriteLine("iprot.ReadListEnd();");
         }

         /// <summary>
-        /// Generates the code to deserialize a collection
-        /// </summary>
-        private void GenerateCollectionDeserialize(Parameter param)
-        {
-            GenerateListDeserialize(param);
-        }
-
-        /// <summary>
-        /// Generates the code to deserialize a set
-        /// </summary>
-        private void GenerateSetDeserialize(Parameter param)
-        {
-            var setElemType = param.ParameterType.GetGenericArguments()[0];
-
-            WriteLine("{0} = new HashSet<{1}>();", ToTitleCase(param.Name),
-                      ConvertToGenericArgsString(param.ParameterType));
-
-            var setName = string.Format("_set{0}", GenericIndex++);
-            WriteLine("var {0} = iprot.ReadSetBegin();", setName);
-
-            var iterName = string.Format("_i{0}", GenericIndex++);
-            WriteLine("for (var {0} = 0; {0} < {1}.Count; ++{0})",
-                      iterName, setName);
-
-            WriteStartBraceIndent();
-
-            GenerateContainerSingleElementDeserialization(setElemType, ToTitleCase(param.Name));
-
-            WriteCloseBraceIndent();
-            WriteLine("iprot.ReadSetEnd();");
-        }
-
-        /// <summary>
         /// Generates the code to deserialize a map
         /// </summary>
-        private void GenerateMapDeserialize(Parameter param)
-        {
-            var mapElemType1 = param.ParameterType.GetGenericArguments()[0];
-            var mapElemType2 = param.ParameterType.GetGenericArguments()[1];
-
-            WriteLine("{0} = new Dictionary<{1}>();", ToTitleCase(param.Name),
-                      ConvertToGenericArgsString(param.ParameterType));
+        private void GenerateMapDeserialize(Type type, string name)
+        {
+            var mapElemType1 = type.GetGenericArguments()[0];
+            var mapElemType2 = type.GetGenericArguments()[1];
+
+            WriteLine("{0} = new Dictionary<{1}>();", ToTitleCase(name),
+                      ConvertToGenericArgsString(type));

             var mapName = string.Format("_set{0}", GenericIndex++);
             WriteLine("var {0} = iprot.ReadMapBegin();", mapName);
@@ -1431,63 +1214,10 @@

             WriteStartBraceIndent();

-            GenerateContainerDoubleElementDeserialization(mapElemType1, mapElemType2, ToTitleCase(param.Name));
+            GenerateContainerDoubleElementDeserialization(mapElemType1, mapElemType2, ToTitleCase(name));

             WriteCloseBraceIndent();
             WriteLine("iprot.ReadMapEnd();");
-        }
-
-        /// <summary>
-        /// Generates the code to deserialize a container element
-        /// </summary>
-        private void GenerateContainerSingleElementDeserialization(Type elemType, string containerName)
-        {
-
-            var elemName = string.Format("_elem{0}", GenericIndex++);
-
-            var thriftType = ConvertFromTypeToThrift(elemType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                case TType.Void:
-                    throw new NotSupportedException();
-                case TType.Struct:
-                case TType.Exception:
-                case TType.Class:
-                    WriteLine("var {0} = new {1}Impl();", elemName, elemType.Name);
-                    WriteLine("{0}.Read(iprot);", elemName);
-
-                    var elemName2 = string.Format("_elem{0}", GenericIndex++);
-                    WriteLine("var {0} = new {1}();", elemName2, elemType.FullName);
-                    GenerateStructInit(elemType, elemName, elemName2);
-                    WriteLine("{0}.Add({1});", containerName, elemName2);
-                    break;
-                case TType.Bool:
-                case TType.Byte:
-                case TType.Double:
-                case TType.I16:
-                case TType.I32:
-                case TType.I64:
-                case TType.String:
-                    var enumCast = "";
-                    if (elemType.IsEnum)
-                        enumCast = String.Format("({0})", elemType.FullName);
-                    WriteLine("{0}.Add({1}iprot.Read{2}());", containerName, enumCast, thriftType.ToString());
-                    break;
-                case TType.Guid:
-                    WriteLine("{0}.Add(new System.Guid(iprot.ReadString()));", containerName);
-                    break;
-                case TType.DateTime:
-                    WriteLine("{0}.Add(new System.DateTime(iprot.ReadI64()));", containerName);
-                    break;
-                default:
-                    throw new NotImplementedException();
-            }
-
         }

         /// <summary>
@@ -1498,58 +1228,10 @@
             var elemName1 = string.Format("_elem{0}", GenericIndex++);
             var elemName2 = string.Format("_elem{0}", GenericIndex++);

-            GenerateContainerDoubleElementDeserializationAux(elemType1, elemName1);
-            GenerateContainerDoubleElementDeserializationAux(elemType2, elemName2);
+            GenerateTypeDeserialization(elemType1, elemName1, false);
+            GenerateTypeDeserialization(elemType2, elemName2, false);

             WriteLine("{0}.Add({1}, {2});", containerName, elemName1, elemName2);
-
-        }
-
-        /// <summary>
-        /// Auxiliary method to generate the code to deserialize a  double element container
-        /// </summary>
-        private void GenerateContainerDoubleElementDeserializationAux(Type elemType, string elemName)
-        {
-            var elemNameImpl = string.Format("_elem{0}", GenericIndex++);
-            var thriftType = ConvertFromTypeToThrift(elemType);
-
-            switch (thriftType)
-            {
-                case TType.List:
-                case TType.Map:
-                case TType.Set:
-                case TType.Collection:
-                case TType.Void:
-                    throw new NotSupportedException();
-                case TType.Struct:
-
-                case TType.Exception:
-                    GenerateStructInit(elemType, elemName, elemNameImpl, false);
-                    break;
-                case TType.Class:
-                    GenerateStructInit(elemType, elemName, elemNameImpl, false);
-                    break;
-                case TType.Bool:
-                case TType.Byte:
-                case TType.Double:
-                case TType.I16:
-                case TType.I32:
-                case TType.I64:
-                case TType.String:
-                    var enumCast = "";
-                    if (elemType.IsEnum)
-                        enumCast = String.Format("({0})", elemType.FullName);
-                    WriteLine("var {0} = {1}iprot.Read{2}();", elemName, enumCast, thriftType.ToString());
-                    break;
-                case TType.Guid:
-                    WriteLine("var {0} = new System.Guid(iprot.ReadString());", elemName);
-                    break;
-                case TType.DateTime:
-                    WriteLine("var {0} = new System.DateTime(iprot.ReadI64());", elemName);
-                    break;
-                default:
-                    throw new NotImplementedException();
-            }
         }

         #endregion
@@ -1557,6 +1239,18 @@
         #endregion

         #region Type Conversion
+
+        private static string PrettyName(Type type)
+        {
+            if (type.GetGenericArguments().Length == 0)
+            {
+                return type.FullName;
+            }
+            var genericArguments = type.GetGenericArguments();
+            var typeDefeninition = type.Name;
+            var unmangledName = typeDefeninition.Substring(0, typeDefeninition.IndexOf("`"));
+            return unmangledName + "<" + String.Join(",", genericArguments.Select(PrettyName)) + ">";
+        }

         /// <summary>
         /// Checks if type of instance is a generic type and if it is of the type of genericType
@@ -1644,18 +1338,14 @@
                 return TType.Struct;
             else if (type == typeof(Exception) || type.IsSubclassOf(typeof(Exception)))
                 return TType.Exception;
-            else if (IsInstanceOfGenericType(typeof(IList<>), type))
-                return TType.List;
             else if (IsInstanceOfGenericType(typeof(IDictionary<,>), type))
                 return TType.Map;
-            else if (IsInstanceOfGenericType(typeof(ISet<>), type))
-                return TType.Set;
             else if (IsInstanceOfGenericType(typeof(ICollection<>), type))
-                return TType.Collection;
+                return TType.List;
             else if (type.IsClass)
                 return TType.Class;

-            throw new NotImplementedException();
+            throw new NotImplementedException("Unhandle type "+type);
         }

         /// <summary>
@@ -1709,8 +1399,6 @@
                     return ConvertToTypeString(type.GetElementType()) +"[]";
                 case TType.List:
                 case TType.Map:
-                case TType.Set:
-                case TType.Collection:
                     return ConvertToGenericTypeString(type, thriftType);
             }

@@ -1735,12 +1423,6 @@
                 case TType.Map:
                     sb.Append("Dictionary<");
                     break;
-                case TType.Set:
-                    sb.Append("ISet<");
-                    break;
-                case TType.Collection:
-                    sb.Append("ICollection<");
-                    break;
             }

             sb.Append(ConvertToGenericArgsString(type, thriftType));


- Added optimization that simplifies extended moves

--- Source/Mosa.Compiler.Framework/Stages/SSAOptimizations.cs
+++ Source/Mosa.Compiler.Framework/Stages/SSAOptimizations.cs
@@ -42,6 +42,7 @@
 		private int foldIntegerCompareBranch = 0;
 		private int reduceZeroExtendedMove = 0;
 		private int foldIntegerCompare = 0;
+		private int simplifyExtendedMove = 0;

 		private Stack<int> worklist = new Stack<int>();

@@ -52,6 +53,8 @@
 			// Unable to optimize SSA w/ exceptions or finally handlers present
 			if (BasicBlocks.HeadBlocks.Count != 1)
 				return;
+
+			trace = CreateTrace();

 			// initialize worklist
 			foreach (BasicBlock block in BasicBlocks)
@@ -95,6 +98,7 @@
 			UpdateCounter("SSAOptimizations.ReduceTruncationAndExpansion", reduceTruncationAndExpansion);
 			UpdateCounter("SSAOptimizations.FoldIntegerCompareBranch", foldIntegerCompareBranch);
 			UpdateCounter("SSAOptimizations.FoldIntegerCompare", foldIntegerCompare);
+			UpdateCounter("SSAOptimizations.SimplifyExtendedMove", simplifyExtendedMove);
 			UpdateCounter("SSAOptimizations.ReduceZeroExtendedMove", reduceZeroExtendedMove);
 			UpdateCounter("SSAOptimizations.BlockRemoved", blockRemovedCount);

@@ -105,10 +109,6 @@
 		{
 			if (context.IsEmpty)
 				return;
-
-			trace = CreateTrace();
-
-			//if (trace.IsLogging) trace.Log("@REVIEW:\t" + context.ToString());

 			SimpleConstantPropagation(context);
 			SimpleCopyPropagation(context);
@@ -131,6 +131,7 @@
 			SimplifyExtendedMoveWithConstant(context);
 			StrengthReductionIntegerCompareBranch(context);
 			ReduceTruncationAndExpansion(context);
+			SimplifyExtendedMove(context);
 		}

 		/// <summary>
@@ -273,33 +274,45 @@
 			}
 		}

-		private bool CanCopyPropagation(Operand result, Operand destination)
-		{
-			if (result.IsPointer && destination.IsPointer)
+		private bool CanCopyPropagation(Operand source, Operand destination)
+		{
+			if (source.IsPointer && destination.IsPointer)
 				return true;

-			if (result.IsReferenceType && destination.IsReferenceType)
+			if (source.IsReferenceType && destination.IsReferenceType)
 				return true;

-			if (result.Type.IsArray & destination.Type.IsArray & result.Type.ElementType == destination.Type.ElementType)
+			if (source.Type.IsArray & destination.Type.IsArray & source.Type.ElementType == destination.Type.ElementType)
 				return true;

-			if (result.Type.IsUI1 & destination.Type.IsUI1)
+			if (source.Type.IsUI1 & destination.Type.IsUI1)
 				return true;

-			if (result.Type.IsUI2 & destination.Type.IsUI2)
+			if (source.Type.IsUI2 & destination.Type.IsUI2)
 				return true;

-			if (result.Type.IsUI4 & destination.Type.IsUI4)
+			if (source.Type.IsUI4 & destination.Type.IsUI4)
 				return true;

-			if (result.Type.IsUI8 & destination.Type.IsUI8)
+			if (source.Type.IsUI8 & destination.Type.IsUI8)
 				return true;

-			if (result.IsValueType || destination.IsValueType)
+			if (NativePointerSize == 4 && destination.IsI && (source.IsI4 || source.IsU4))
+				return true;
+
+			if (NativePointerSize == 4 && source.IsI && (destination.IsI4 || destination.IsU4))
+				return true;
+
+			if (NativePointerSize == 8 && destination.IsI && (source.IsI8 || source.IsU8))
+				return true;
+
+			if (NativePointerSize == 8 && source.IsI && (destination.IsI8 || destination.IsU8))
+				return true;
+
+			if (source.IsValueType || destination.IsValueType)
 				return false;

-			if (result.Type == destination.Type)
+			if (source.Type == destination.Type)
 				return true;

 			return false;
@@ -1319,5 +1332,34 @@
 			foldIntegerCompare++;
 			instructionsRemovedCount++;
 		}
+
+		/// <summary>
+		/// Simplifies sign/zero extended move
+		/// </summary>
+		/// <param name="context">The context.</param>
+		private void SimplifyExtendedMove(Context context)
+		{
+			if (context.IsEmpty)
+				return;
+
+			if (!(context.Instruction == IRInstruction.ZeroExtendedMove || context.Instruction == IRInstruction.SignExtendedMove))
+				return;
+
+			if (!context.Result.IsVirtualRegister || !context.Operand1.IsVirtualRegister)
+				return;
+
+			if (!((NativePointerSize == 4 && context.Result.IsI && (context.Operand1.IsI4 || context.Operand1.IsU4)) ||
+				(NativePointerSize == 4 && context.Operand1.IsI && (context.Result.IsI4 || context.Result.IsU4)) ||
+				(NativePointerSize == 8 && context.Result.IsI && (context.Operand1.IsI8 || context.Operand1.IsU8)) ||
+				(NativePointerSize == 8 && context.Operand1.IsI && (context.Result.IsI8 || context.Result.IsU8))))
+				return;
+
+			AddOperandUsageToWorkList(context);
+			if (trace.Active) trace.Log("*** SimplifyExtendedMove");
+			if (trace.Active) trace.Log("BEFORE:\t" + context.ToString());
+			context.SetInstruction(IRInstruction.Move, context.Result, context.Operand1);
+			simplifyExtendedMove++;
+			if (trace.Active) trace.Log("AFTER: \t" + context.ToString());
+		}
 	}
 }


ADDED: Slash.GameBase - Added event type for logging output.

--- Source/Slash.GameBase/Source/Events/FrameworkEventType.cs
+++ Source/Slash.GameBase/Source/Events/FrameworkEventType.cs
@@ -122,5 +122,15 @@
         ///   </para>
         /// </summary>
         ComponentDisabled,
+
+        /// <summary>
+        ///   <para>
+        ///     A generic logging event.
+        ///   </para>
+        ///   <para>
+        ///     Event data: <see cref="string"/> (Log message).
+        ///   </para>
+        /// </summary>
+        Logging,
     }
 }


[Toolkit.Graphics] RenderTarget2D update

--- Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTarget2D.cs
+++ Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTarget2D.cs
@@ -102,9 +102,7 @@
                 }

                 rtv = new RenderTargetView(GraphicsDevice, Resource, rtvDescription);
-                RenderTargetViews[rtvIndex] = rtv;
-
-                ToDispose(rtv);
+                RenderTargetViews[rtvIndex] = ToDispose(rtv);
             }

             return rtv;
@@ -158,7 +156,7 @@
         /// <msdn-id>ff476521</msdn-id>
         ///   <unmanaged>HRESULT ID3D11Device::CreateTexture2D([In] const D3D11_TEXTURE2D_DESC* pDesc,[In, Buffer, Optional] const D3D11_SUBRESOURCE_DATA* pInitialData,[Out, Fast] ID3D11Texture2D** ppTexture2D)</unmanaged>
         ///   <unmanaged-short>ID3D11Device::CreateTexture2D</unmanaged-short>
-        public static RenderTarget2D New(int width, int height, PixelFormat format, int mipCount = 1, int arraySize = 1, bool isUnorderedReadWrite = false)
+        public static RenderTarget2D New(int width, int height, PixelFormat format, bool isUnorderedReadWrite = false, int mipCount = 1, int arraySize = 1)
         {
             return new RenderTarget2D(NewDescription(width, height, format, isUnorderedReadWrite, mipCount, 1));
         }


adding tests and removing code

adding tests and removing code

--- Surface/NakedObjects.Surface.Nof4/Utility/SurfaceUtils.cs
+++ Surface/NakedObjects.Surface.Nof4/Utility/SurfaceUtils.cs
@@ -10,6 +10,7 @@
 using System.Reflection;
 using NakedObjects.Architecture;
 using NakedObjects.Architecture.Spec;
+using NakedObjects.Core;
 using NakedObjects.Core.Util;


More tests on collection-contrib actions

--- Test/NakedObjects.SystemTest/Attributes/TestAttributes.cs
+++ Test/NakedObjects.SystemTest/Attributes/TestAttributes.cs
@@ -91,6 +91,7 @@
                     new TestServiceValidateProgrammaticUpdates(),
                     new SimpleRepository<Contributee>(),
                     new SimpleRepository<Contributee2>(),
+                    new SimpleRepository<Contributee3>(),
                     new TestServiceContributedAction(),
                     new SimpleRepository<FinderAction1>(),
                     new TestServiceFinderAction()
@@ -124,6 +125,29 @@
             Assert.AreEqual("Collection Contributed Action1", actions[1].Name);
             Assert.AreEqual("Collection Contributed Action2", actions[2].Name);
             Assert.AreEqual("Collection Contributed Action3", actions[3].Name);
+        }
+
+        [TestMethod]
+        public virtual void CollectionContributedToSubClass() {
+            var obj = NewTestObject<Contributee3>().GetDomainObject();
+            var adapter = NakedObjectsFramework.NakedObjectManager.CreateAdapter(obj, null, null);
+            var actions = (adapter.Spec as IObjectSpec).GetCollectionContributedActions();
+
+            Assert.AreEqual(4, actions.Count());
+            Assert.IsTrue(actions[0] is IActionSpec);
+            Assert.AreEqual("Collection Contributed Action", actions[0].Name);
+            Assert.AreEqual("Collection Contributed Action1", actions[1].Name);
+            Assert.AreEqual("Collection Contributed Action2", actions[2].Name);
+            Assert.AreEqual("Collection Contributed Action3", actions[3].Name);
+        }
+
+        [TestMethod]
+        public virtual void CollectionContributedNotToAnotherClass() {
+            var obj = NewTestObject<Contributee>().GetDomainObject();
+            var adapter = NakedObjectsFramework.NakedObjectManager.CreateAdapter(obj, null, null);
+            var actions = (adapter.Spec as IObjectSpec).GetCollectionContributedActions();
+
+            Assert.AreEqual(0, actions.Count());
         }

         #endregion
@@ -1055,6 +1079,7 @@
         public DbSet<Validateprogrammaticupdates2> ValidateProgrammaticUpdates2s { get; set; }
         public DbSet<Contributee> Contributees { get; set; }
         public DbSet<Contributee2> Contributee2s { get; set; }
+        public DbSet<Contributee3> Contributee3s { get; set; }
         public DbSet<FinderAction1> Exclude1s { get; set; }
     }

@@ -1720,6 +1745,11 @@
         public void NativeAction() { }
     }

+    public class Contributee3 : Contributee2 {
+
+        public void NativeAction3() { }
+    }
+
     public class TestServiceFinderAction {

         [FinderAction()]


Fix invalid menu reference

Fix invalid menu reference

--- TimeLog.Api.Documentation/Views/Shared/_Navigation.cshtml
+++ TimeLog.Api.Documentation/Views/Shared/_Navigation.cshtml
@@ -98,7 +98,7 @@

E-conomic

Exact Online

Fortnox

-
Björn Lundén

+
Björn Lundén

Microsoft Dynamics NAV

Dinero

Uniconta


#439 Fix GetResponseBodyAsString() causes an exception

--- Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
+++ Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs
@@ -28,9 +28,9 @@
         /// <summary>
         ///     Initializes a new instance of the <see cref="SessionEventArgsBase" /> class.
         /// </summary>
-        internal SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
+        private SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
             CancellationTokenSource cancellationTokenSource)
-            : this(server, endPoint, cancellationTokenSource, null)
+
         {
             bufferSize = server.BufferSize;
             bufferPool = server.BufferPool;
@@ -39,7 +39,7 @@

         protected SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
             CancellationTokenSource cancellationTokenSource,
-            Request request)
+            Request request) : this(server, endPoint, cancellationTokenSource)
         {
             CancellationTokenSource = cancellationTokenSource;


Fix integrity analysis to work with loops

--- Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs
+++ Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs
@@ -132,7 +132,7 @@
                         if (!labelStackSize.TryGetValue(label, out Dictionary<int, int> otherStack))
                             labelStackSize[label] = otherStack = new Dictionary<int, int>();

-                        otherStack.Add(i - 1, stack);
+                        otherStack[i - 1] = stack;
                         if (otherStack.Values.Distinct().Count() > 1 || (otherStack.Count == 1 && !otherStack.ContainsValue(stack)))
                         {
                             string otherDesc = string.Join(", ", otherStack.Select(x => $"{x.Key:X4}=>{x.Value}"));


update

update

--- Unity/Demos/Assets/Scripts/DragonBones/unity/UnitySlot.cs
+++ Unity/Demos/Assets/Scripts/DragonBones/unity/UnitySlot.cs
@@ -258,7 +258,7 @@
                 if (_renderer == null)
                 {
                     _renderer = _renderDisplay.AddComponent<MeshRenderer>();
-                    _renderer.sortingOrder = _zOrder;
+                    //_renderer.sortingOrder = _zOrder;
                 }

                 _meshFilter = _renderDisplay.GetComponent<MeshFilter>();


added base class to visaupdateimageoptions

--- VisaCheckout/VisaHelper/Options/VisaUpdateImageOptions.cs
+++ VisaCheckout/VisaHelper/Options/VisaUpdateImageOptions.cs
@@ -17,7 +17,7 @@
     /// <summary>
     /// Visa Update Image options.
     /// </summary>
-    public class VisaUpdateImageOptions : IOptions
+    public class VisaUpdateImageOptions : OptionsBase, IOptions
     {
         public const string ProductionUrl = "https://secure.checkout.visa.com/wallet-services-web/payment/updatepaymentinfo.gif";
         public const string SandboxUrl = "https://sandbox.secure.checkout.visa.com/wallet-services-web/payment/updatepaymentinfo.gif";