Fixed an issue where built int Enums would be converted to int type for fields. Bumped package version to 1.4.3.

This commit is contained in:
MattMo 2023-03-24 08:21:12 -07:00
parent f2db3bddbf
commit 0c8467f942
3 changed files with 67 additions and 62 deletions

View File

@ -32,6 +32,8 @@ namespace MontoyaTech.Rest.Net.Example
public class User : BaseUser
{
public PlatformID MachineType;
public string Name = null;
public List<string> List = null;

View File

@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.4.2</Version>
<Version>1.4.3</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup>

View File

@ -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
{