ConvertTo behavior with EnumAsInt changed in 5.5

The ConvertTo<>() does not convert properly EnumAsInt for value 0.
The same code works in 5.4 and previous version.
Any advice ? Thanks

using System;
using ServiceStack;
using ServiceStack.DataAnnotations;

namespace servicestackConvertToEnum
{

[EnumAsInt]
public enum MyEnum
{
    ZeroValue = 0,
    OneValue = 1,
    DefaultValue = 2,
};

class Source
{
    public MyEnum myProperty { get; set; } = MyEnum.DefaultValue;
}

class Target
{
    public MyEnum myProperty { get; set; } = MyEnum.DefaultValue;
}

class Program
{
    static void Main(string[] args)
    {
        Source instanceOfSource = new Source() { myProperty = MyEnum.ZeroValue };
        Target instanceOfTarget = instanceOfSource.ConvertTo<Target>();

        Console.WriteLine($"myProperty source={instanceOfSource.myProperty} target={instanceOfTarget.myProperty}");
    }
}

}

Output:
myProperty source=ZeroValue target=DefaultValue

The value is not “copied” during the ConvertTo.

This should now be resolved from this commit. This change is available from v5.6.1 that’s now available on MyGet.

thx for the repro!

1 Like

Thanks for fast fix !

1 Like