ServiceStackVS 5.6 enumerations error in VS2017

Upgraded from ServiceStack 5.5 to 5.6.
Using the latest Visual Studio 2017 version and ServiceStackVS extension.
Running “Update ServiceStack reference” from Visual Studio project generates an updated DTO with broken enumerations from the service. Instead of creating “key = value” it generates “key = key”. Trying to exclude the enumeration types in the instruction does not help, so the only way is to remove the enumerations from the generated file and putting the proper enumerations in a separate file.
This issue seems only to affect 5.6 as it was working properly on 5.5

Note the VS Extension doesn’t generate the DTOs, it calls your Service to retrieve its generated DTOs, i.e. it’s being generated by ServiceStack.dll from your C# DTOs, not the VS.NET Extension.

Can you please provide the original C# DTO you’re using as well as the generated enum it’s generating.

In its simplest form (I have multiple enumerations that I setup in DTOs):
On the DTO:

   public class OrderStatusMessageResponse
    {
        public OrderStatusData OrderStatusData { get; set; }
    }
   public class OrderStatusData
    {
        public string WebOrderNo { get; set; }
        public int Status { get; set; }
        public OrderType OrderType { get; set; }
    }
    public enum OrderType
    {
        NORMAL = 0,
        REPLACEMENT = 1001,
        REFUND = 1002
    }

In the client C# project, after running “Update ServiceStack Reference”:

    public enum OrderType
    {
        NORMAL = NORMAL,
        REPLACEMENT = REPLACEMENT,
        REFUND = REFUND,
    }

Ok yeah that’s a bug, in the meantime you can annotate them with [Flags] to have them use their integer values, e.g:

[Flags]
public enum OrderType
{
    NORMAL = 0,
    REPLACEMENT = 1001,
    REFUND = 1002
}

This should now be resolved from the latest v5.6.1 on MyGet.

Confirmed that the issue has been resolved after pulling v5.6.1 from MyGet and updating the reference. Thank you for a prompt action!

1 Like