diff --git a/Rest.Net.Example/Program.cs b/Rest.Net.Example/Program.cs index a94e4c7..1cf4a9f 100644 --- a/Rest.Net.Example/Program.cs +++ b/Rest.Net.Example/Program.cs @@ -32,6 +32,8 @@ namespace MontoyaTech.Rest.Net.Example public class User : BaseUser { + public PlatformID MachineType; + public string Name = null; public List List = null; diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index 0f72126..2e6cbed 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.4.2 + 1.4.3 Logo_Symbol_Black_Outline.png diff --git a/Rest.Net/RestClientGenerator.cs b/Rest.Net/RestClientGenerator.cs index 7c755d1..a3cb914 100644 --- a/Rest.Net/RestClientGenerator.cs +++ b/Rest.Net/RestClientGenerator.cs @@ -215,69 +215,72 @@ namespace MontoyaTech.Rest.Net { var typeCode = Type.GetTypeCode(type); - switch (typeCode) + if (typeCode != TypeCode.Object && !type.IsEnum) { - case TypeCode.Boolean: - return "bool"; - case TypeCode.Byte: - return "byte"; - case TypeCode.Char: - return "char"; - case TypeCode.DateTime: - return "DateTime"; - case TypeCode.Decimal: - return "decimal"; - case TypeCode.Double: - return "double"; - case TypeCode.Int16: - return "short"; - case TypeCode.Int32: - return "int"; - case TypeCode.Int64: - return "long"; - case TypeCode.SByte: - return "sbyte"; - case TypeCode.Single: - return "float"; - case TypeCode.String: - return "string"; - case TypeCode.UInt16: - return "ushort"; - case TypeCode.UInt32: - return "uint"; - case TypeCode.UInt64: - return "ulong"; - default: - var builder = new StringBuilder(); - - builder.Append(type.Namespace); - - int genericSymbol = type.Name.IndexOf('`'); - - if (genericSymbol == -1) - builder.Append(".").Append(type.Name); - else - builder.Append(".").Append(type.Name.Substring(0, genericSymbol)); - - var genericArguments = type.GetGenericArguments(); - - if (genericArguments != null && genericArguments.Length > 0) - { - builder.Append("<"); - - for (int i = 0; i < genericArguments.Length; i++) - { - if (i > 0) - builder.Append(", "); - - builder.Append(this.GetTypeFullyResolvedName(genericArguments[i])); - } - - builder.Append(">"); - } - - return builder.ToString(); + switch (typeCode) + { + case TypeCode.Boolean: + return "bool"; + case TypeCode.Byte: + return "byte"; + case TypeCode.Char: + return "char"; + case TypeCode.DateTime: + return "DateTime"; + case TypeCode.Decimal: + return "decimal"; + case TypeCode.Double: + return "double"; + case TypeCode.Int16: + return "short"; + case TypeCode.Int32: + return "int"; + case TypeCode.Int64: + return "long"; + case TypeCode.SByte: + return "sbyte"; + case TypeCode.Single: + return "float"; + case TypeCode.String: + return "string"; + case TypeCode.UInt16: + return "ushort"; + case TypeCode.UInt32: + return "uint"; + case TypeCode.UInt64: + return "ulong"; + } } + + var builder = new StringBuilder(); + + builder.Append(type.Namespace); + + int genericSymbol = type.Name.IndexOf('`'); + + if (genericSymbol == -1) + builder.Append(".").Append(type.Name); + else + builder.Append(".").Append(type.Name.Substring(0, genericSymbol)); + + var genericArguments = type.GetGenericArguments(); + + if (genericArguments != null && genericArguments.Length > 0) + { + builder.Append("<"); + + for (int i = 0; i < genericArguments.Length; i++) + { + if (i > 0) + builder.Append(", "); + + builder.Append(this.GetTypeFullyResolvedName(genericArguments[i])); + } + + builder.Append(">"); + } + + return builder.ToString(); } else {