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.