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 class User : BaseUser
{ {
public PlatformID MachineType;
public string Name = null; public string Name = null;
public List<string> List = null; public List<string> List = null;

View File

@ -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.4.2</Version> <Version>1.4.3</Version>
<PackageReleaseNotes></PackageReleaseNotes> <PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon> <PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup> </PropertyGroup>

View File

@ -215,69 +215,72 @@ namespace MontoyaTech.Rest.Net
{ {
var typeCode = Type.GetTypeCode(type); var typeCode = Type.GetTypeCode(type);
switch (typeCode) if (typeCode != TypeCode.Object && !type.IsEnum)
{ {
case TypeCode.Boolean: switch (typeCode)
return "bool"; {
case TypeCode.Byte: case TypeCode.Boolean:
return "byte"; return "bool";
case TypeCode.Char: case TypeCode.Byte:
return "char"; return "byte";
case TypeCode.DateTime: case TypeCode.Char:
return "DateTime"; return "char";
case TypeCode.Decimal: case TypeCode.DateTime:
return "decimal"; return "DateTime";
case TypeCode.Double: case TypeCode.Decimal:
return "double"; return "decimal";
case TypeCode.Int16: case TypeCode.Double:
return "short"; return "double";
case TypeCode.Int32: case TypeCode.Int16:
return "int"; return "short";
case TypeCode.Int64: case TypeCode.Int32:
return "long"; return "int";
case TypeCode.SByte: case TypeCode.Int64:
return "sbyte"; return "long";
case TypeCode.Single: case TypeCode.SByte:
return "float"; return "sbyte";
case TypeCode.String: case TypeCode.Single:
return "string"; return "float";
case TypeCode.UInt16: case TypeCode.String:
return "ushort"; return "string";
case TypeCode.UInt32: case TypeCode.UInt16:
return "uint"; return "ushort";
case TypeCode.UInt64: case TypeCode.UInt32:
return "ulong"; return "uint";
default: case TypeCode.UInt64:
var builder = new StringBuilder(); return "ulong";
}
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();
} }
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 else
{ {